Worklight: two users Same device Push subscription - push-notification

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.

Related

Does FCM send notifications to mobile and web at the same time?

The logic of my project is that I have to send notifications from admin panel to users in web and mobile app at the same time! another meaning:
When the admin send a notification to John Doe I need John to receive the notification on website and mobile app at the same time!
Does FCM can do that ? or I have to send notifications for mobile app and do another thing for web to web which is admin to user on web??
FCM does not guarantee the timing of the receipt of messages. If you send two messages, they will very likely end up on the devices at about the same time, but there is no guarantee that they will. Also consider that one of the devices might not even be on at the time the message is sent - that message simply will not arrive until the device is turned on again.
But you can certainly write code to send as many messages as you need to as many devices as you want, and simply accept the results.
Yes, it's possible. That's the nice thing about Firebase services, so that you don't have to write entirely different code for the same functionality for each platform separately.

How to send a push notification from the Firebase console to a specific GCM/FCM device token ID

In Urban Airship, when I am composing a notification, I can target specific users by searching for a Urban Airship channel_id (device ID):
I sent from Urban Airship the push notification that I am showing above, and I received it successfully. Now I want to do the same thing, send a push notification to a specific device, but now using the Firebase console. The problem is that in Firebase, in the step where I need to specify the target, it only allows me to choose User segment or topic. I was expecting to see a third option: Target specific users (for sending notifications to one or many specific GCM/FCM device token IDs. So my alternative is to add a GCM/FCM device token ID to a topic and then send the push notification to that topic, which is something that I have successfully done before. Nonetheless, that would be a workaround and not the way I would prefer to do this. Is it possible to send push notifications to specific users (by defining the target GCM/FCM device token IDs) from the Firebase console? Thank you.
UPDATE 1: See how the Firebase console (https://console.firebase.google.com/) only shows User segment and Topic as the Target:
First Step:
Second Step:
Third Step:
By design, the notification feature in the console is for sending out broadcast-type events. Sending user-specific alerts would be more of a programmatic operation done through the API.
For sending test messages, there is a console tool for this, explained here.
Note that it is possible to send a notification to one device by subscribing a device to any topic and sending the notification to that topic in the console (keep in mind topics are public and you can't prevent users from signing up to them; fine for testing most likely).
Another alternative is to send a message via HTTP or curl. Perhaps the best resource for this is the quickstart/messaging example.

IBM MobileFirst Platform Event Source Push Notification

Let say user A subscribe event source push notification at device A at 10am and subscribe event source push at device B at 11am without unsubscribe. If my backend send the push message, both devices will receive the push message? I actually just want to send the message to the latest devices user have subscribed. Is there anyway to do this?
Like Idan suggested you can inspect push subscriptions in the database . Susbscriptions have an associated timestamp entry . With this you can determine the latest one for the user.
You can then use WL.Server.notifyDevice(userSubscription, device, options) or WL.Server.notifyDeviceSubscription(deviceSubscription, notificationOptions) to target a specific device.
If the user subscribed to two different event sources then yes, the user will receive notifications in both event sources...
There is no built-in mechanism that will prevent "duplicate" subscriptions (of the same user), so perhaps you could implement some sort of a cron job on your server to inspect the subscriptions table in the database and check that there are no duplicate subscriptions. If a duplicate subscription is found, delete the older one.

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.

Resources