I have android app that includes sections. After user login he can follow a section. Inside every section users can add posts. I want when someone posts something on specific section. All followers gets notification of the post. Like what happens on Facebook groups.
I'm using OneSignal. Should I use tags? Also, I see when user clears the cache and re-login to the app. All connected tags are lost. He will not get notifications until he unfollow the section and then re-follow it again. So OneSignal.sendTags get triggered again.
What are the best solution here?
First of all , you can use a firebase solution or you can go with rabbit mq or any other messaging services , so you need to save all the devices token in you users table , and the when you trigger your function you send the notification to all the tokens of the members
you want to notify , this technique is working fine
Related
Many have you have noticed that sometimes we gets notifications according to our needs and Interest.
For Example: Suppose you are using any Hotel Booking App, You entered the city and checked some hotels but didn't booked any hotel and closed the App. You will notice, after few hours or days they will send you notifications according to what I checked on their App(Like some offers or Planning to visit "xyz" city?) How they send such notifications? What they use for last searched cities/hotels of each user and send notification accordingly?
Check fabric and firebase. These provide a very efficient way to keep a track of user's activity over the application.. Now all you have to do is initialise either of these in your application and keep a track of user activities.
And after that you will know the interests of your users and you can notify them accordingly.
I think the question is how do you gather the data to use in the notifications.
For each user you can save events and details on the visited places (in this examples, the hotels in the application) at each step, each activity, each action. You can save all these in the database and with a cron you can send a notification for the users who visited some parts of the application but have not made a booking/purchase today.
I'm using Firebase's FCM for push notifications for an app. There is a need to subscribe to certain topics from the moment the user starts the app.
So far I've handled "topics" and various metrics on our own server, but as we're moving logic parts to their appropriate place to lessen the load on our server, this needs to be moved to Firebase itself.
And we want to handle things a bit differently. Users will be able to subscribe and unsubscribe to/from certain notification groups, however FCM's documentation does not mention which is the time, which callback is the proper place to handle this.
The flow would be the following:
User installs app
User launches app
App updates cached data (information that changes in larger intervals, e.g. every 3-6 months)
App pulls synced data, including topics list, from Google account
App registers device for push notifications
App subscribes user to "all" topic (all users that want to receive generic notifications are registered here. Unsubscribing is only possible if the user unchecks the "send me notifications" option in settings)
App subscribes to the topics synced in step 4
What isn't clear is WHERE to place steps 6 and 7. Do I put it into my implementation of FirebaseInstanceIdService, into OnTokenRefresh on Android, and in Messaging.SharedInstance.Connect or InstanceId.Notifications.ObserveTokenRefresh on iOS? Do I need to re-register to topics when an FCM token change happens?
The app is written in Xamarin, so we're using FCM for both iOS and Android.
Where you place the code for subscribing the token depends entirely up to you. Usually though, it is placed on the initial activity of the app. This ensures that the user will be subscribed to that certain topic.
However in your use-case, you could make a method that checks if the Notification Settings for your app is ticked or not, if yes, subscribe the token, if not, unsubscribe. Then simply call this method on your initial activity.
With regard to "Do I need to re-register to topics when an FCM token change happens?", you don't have to. Referring to this answer by #DiegoGiorgini:
If the token is "refreshed" the topic subscriptions are maintained.
The register to topic should be placed in the View (Activity class in Android). It depends on where you need it. It could be achieved by using this line of code
FirebaseMessaging.Instance.SubscribeToTopic("promotion");
Note that when you subscribes to topic that does not exist, the topic will be created in the server. However the creation requires long time so the topic could not appear instantly in your Firebase console.
Later on, when you want to unsubscribe (probably after logout), just call this inside your View as well.
FirebaseMessaging.Instance.UnsubscribeFromTopic("promotion");
Hope this could help.
I'm working on a doorbell project in which I want to send Push Notification to user when a guest come and ring the doorbell, it should send a Push Notification to the user (i.e owner of house). I want to use Firebase Cloud Messaging for this in my android app.
We are using RaspberryPi as the hardware controller. It will trigger notification to user using FCM on their android device when someone presses their doorbell.(which is not a point of concern.)
My confusion is:
According to this post on SO, FCM will send Push Notification to the predefined 'registration_ids' which we have mentioned in the app.
But in my case, every user will have their different registration ids. Also the number of users are not fixed.
It could be any number of users. Whoever uses the doorbell will have their own id.
So it will be a possible scenario like:
suppose I have not mentioned any registration id in app. 10 users have installed this doorbell at home and someone on the house no 1 presses doorbell button, the FCM will send push notification to all the 10 users. Reason is, the registration id will be same for all the devices who have installed app from PlayStore.
suppose I have mentioned 3 registration id in app. So 3 users will be getting the same Push Notification at the same time.
And if i'm not wrong, if i put only 1 registration id, only 1 user will get notification even if 5 different house's doorbell are pressed, the same user will be notified 5 times.
If i declare a specific registration id to be notified in server side (i.e RaspberryPi), I have to regularly add new registration ids as the number of users increases in my app and update it frequently.
So how do I resolve this problem ?
I haven't started developing this app till now because I'm confused with the first step itself.
If I've gone wrong somewhere, please guide me as I'm new to Push Notifications or FCM. I may not have understood concept of FCM, which is possible but I'm not sure. If this solution is not possible using FCM, suggest me some other options to achieve this please.
A Registration token corresponds to a single app instance (see my answer here).
In your post, it seems like you were confusing the registration id as something that is permanent in the app, which is not.
Whenever a user installs your app, on the first initialization, it should generate it's own Registration token, where you'll have to save that token to your App Server, making sure that you associate it with the corresponding user details.
For your use-case, you could make use of Topic Messaging, where you simply subscribe the user to their corresponding doorbell topic, and every time that specific doorbell is triggered, you send a message to the corresponding topic.
Logic/Code question here.
Hello all,
I am building an social network type of Android app where specific group of people share their views. And for this , I planned to use only Facebook for everything, posting, commenting and all. The posts are posted on a page.
My problem is like this:
Suppose, a user posted a thing through the app, another user comes and interact with the post by commenting.
Now I need to send a notification to the first user that second user interacted with his/her post.
The notification should be on mobile app, not Facebook app.
Any idea, how can I solve this problem?
Any sort of help would be appreciated.
There is no simple solution for this. You may want to look for third-party solutions. Basically,
When a user logs in, send the device token and facebook user id to your server and store them in a database.
When a user makes a post, link the post id to the device token.
When a user comments, get the facebook user id of the parent post, then get the device token, then send a notification to the device token.
We are implementing a mobile app which let users share to-do lists. The idea is to have as little server administration as possible and obviously keep cost down.
For user management and push notifications we will use Parse.com with Cloud Code and PubNub for real time data delivery.
Every user will log in with it facebook' s credentials and subscribe to a read only private channel that only him can read. Every time he create a new to-do list to share with his facebook's friends, the app will make an API call to CloudCode, with it's identity, the data to share and a list of friends. In CloudCode the data is pushed to the PubNub private channels of the list of friends.
In addition in CloudCode the idea is to use PubNub Presence and if the user is offline, send a Push notification.
Is this implementation ok? I'm new to both services and trying to learn. Thanks!
PubNub is appropriate if you are trying to implement a realtime app such as a chat application or a GPS tracking application. But in your case, I think you may not need PubNub's features at all. You can have the afore mentioned functionalities using Parse.com only. The parse push can be used in both the scenarios.
When the user is logged in, and is using the application :- Receive the push, suppress the notification and update the UI with the newly received data.
When the user is not online or logged in, then simply create a notification and add a click listener activity for it.
The reason why I suggest to remove PubNub (for this particular application) is that, PunNub has a different pricing model for loading history. On the free plan, you are limited to one day of message history. On the other hand, you can run this app's backend on Parse.com, almost free cost.
There's nothing in the architecture you describe above that Parse can't handle, including the ability to support Facebook login and external service calls via Cloud Codes Parse.Cloud.httpRequest(). It will do it and do it well thus the answer is yes, this is ok.
Go forth and Parse.