Sending Firebase message to topic to same user on multiple devices - firebase

I have an app that lets users authenticate with phone auth, and subscribe to topics to get notifications. If a user authenticates on two devices like an ipad and iphone, and subscribes to the same topic on both, when I send a message to that topic, it's only received on one of the devices. Is this correct and by design? If the user has an iPhone in their pocket and an iPad at home, the notifications may only get displayed on the iPad at home, and they miss the notification.

Yes, this is correct. When you create a topic and lets say a user subscribe to that topic, then that device will be associated with that topic.
If the user opens his account in another device and you send a notification, it won't be received on that device. So, it will only be received on the device the user subscribed to that topic. If the user is subscribed to a topic on multiple devices, all devices will receive the notification.
Also, if only one user is subscribed to that topic and he unsubscribe then it is no longer a topic.

Related

How to unlink a device in Firebase notification if a user is no longer connected

I understand that Firebase can detect if a user uninstalls an app from a device and will thus mark that device UID as no longer linked and notify us when we decide to send a notification to that device.
But my question is what can i do when i user logs out or decides to log in with a different login, as far as firebase is concerned it will have 2 users that will get notifications on that device? I could be wrong and Firebase notification will notice that 2 users are connected to the same device on the same app and mark all other device UIDs as no longer linked and remove them? Is this a correct assumption?
I just want to avoid sending notifications to an app that is no longer linked to a particular user.
Can someone tell me where i can go to read more about how Firebase Notifications are actually handled?
Thanks

Firebase messaging subscribe to topics after token refresh and multiple devices sync

From my testing and understanding,
I noticed that when a user subscribes to a topic using Device A, and logs in on Device B.
Device B will not receive that topic's notification unless the user subscribes to that topic from Device B as well. How can i have both devices receive the notification when only one device subscribes?
When using the FirebaseMessaging.instance.onTokenRefresh.listen() stream, and the users token changes, how can i subscribe his new token to his previously subscribed topics? (Note: I store them in the database).

Worklight send push notifications without username

I want to create an application which have 2 modes: non-logged-in and logged-in (having username).
I want to send push notifications to devices in both modes. The non-logged-in devices should receive notifications such as general announcements, new events, etc. The logged-in mode devices will also receive same notifications and few more.
Now what I want to do is to subscribe the device to receive notifications for non-logged-in mode then once the user logs in to his account from that device I want to unsubscribe the previous non-logged-in notifications.
I've read the answer to this question : Worklight: Push notification without User ID I think that I can play with onUserSubscribe callback when registering the user and unsubscribe the userId of the persistent cookie.
Is this a good idea ? Is there another suggestion ?
My thinking is that you could register an app to 2 event sources.
The first event source will handle the general notifications that an app should receive, whether a user is logged-in or not.
The second event source will handle the notifications for logged-in users.
When the app launches, subscribe to the first event source.
When the user decides to log-in, subscribe to the second event.
You should allow the user to unsubscribe from both if s/he so chooses, as well.
Additional information:
IBM Worklight 6.1 Information Center: search for "push notifications"
Push Notifications training module
So what you're trying to achieve is push notifications broadcast (send to all users). This is something that you'll be able to do with upcoming Worklight 6.2 release. You will not have to subscribe users according to username, but will be able to specify tags during subscription. And after that you'll be able to send push notifications according to this tags.

Push notification IOS/Android

I am writing back end for mobile app, we are sending pushes (something like one user add
another to buddies) he should accept it or decline via push notification(it is required), server got some feedback from notification, and do something.
I am familiar with two techniques about pushes, first I push directly on device using token, second is abstraction when user subscribes for channel and I send push notification on this channel. Id in my application is email, and I suggest to update device token in the database each time user login, and send push on it, but how should I identify device OS ?(IOS/Android)
1) How to scale it, if user have multiple devices, and when user will logout, and login from other device ?
May be there is common solutions for this problem.

Worklight: two users Same device Push subscription

I have a scenario presented by business team that: one person has device and he subscribed for Push Notification, later on his wife use the same device and subscribe for Push on her account.
Now in this case:
will Push go two times to the same device?
Or, the previous device subscription will be overridden
Plus, my App saves all Push notification messages on user's devices (as transaction history) , shouldn't be the problem!
To handle this scenario, what could be the possible options?
I am using Worklight Consumer 5.0.5
Thanks
Once you subscribe with different user on a same device the old subscription will be deleted. This is done for security reasons, e.g. in case you sell/loose/give your device new user should not get notifications of old one.

Resources