IBM MobileFirst Platform Event Source Push Notification - 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.

Related

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.

Not Seeing "Opened" Firebase Notification Stats

I'm manually handling firebase notifications by overriding the onHandle intent of the FirebaseMessagingService.
And using the intent I generate a notification.
Is there a way to manually report the notification opened to the Firebase at all because I'm not getting opened statistics reported back to the firebase console.
As above, even when letting firebase notifications get handled per normal, these open notifications are not being reported either.
Thanks!
The stats shown in the notifications panel of the Firebase console are only for messages sent from that notification panel. There is currently no way to trigger the stats for messages sent through the Firebase Cloud Messaging API directly.
Update: since late 2018 the Firebase now also reports messages sent through called to the Firebase Cloud Messaging API.
According to https://firebase.google.com/docs/cloud-messaging/understand-delivery only "Sends" work for data-only messages:
Sends — The data message or notification message has been enqueued for delivery or has been successfully passed to a third-party service like APNs for delivery. See lifetime of a message for more information.
Impressions (available only for notification messages on Android devices) — The display notification has been displayed on the device.
Opens — The user opened the notification message.
For those curious to know my workaround at this time.
We run push campaigns.
For each campaign we created a distinct, reusable event.
We register the event "campaign_received" and "campaign_opened"
When a message is received, we trigger the event.
When the notification is opened, we trigger the event.
Then, under each event, we just select the event, and file their stats per day, week, month, etc.
One needs to select the event to get to the event dashboard area, since the event list view shows the total amount of events sent and or received.
For bespoke notifications the 500 event limit might be reached quite quickly, so be sure to bundle your notifications into reusable event categories if possible.

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.

worklight send push notification for all subscribed users

I have to schedule a downtime in order to do some stuff on the production server. My customer wants me to send a push notification to all the subscribed users in order to notify them by the downtime.
Is that possible? If I want to do it even by code will it be possible?
I'm on worklight 6.0.0.0
Using the Worklight Console you can notify the users of your application taking advantage of the "Active, Notifying" setting. This will allow you to display a notification message on startup telling the customer of scheduled downtime. Even when the downtime occurs you can use the same mechanism and set the application to "disabled" with a notification message stating the application is currently down. Please look at the following documentation for more information:
Displaying a notification message on application startup:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.worklight.help.doc%2Fadmin%2Ft_displaying_a_notification_message_on_app_startup.html
Defining administrator messages from Worklight Console in multiple languages:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.worklight.help.doc%2Fadmin%2Ft_defining_multi-language_admin_notifications.html
Maybe you can use Wl.Server.sendMessage, you just need to send the applicationId and notificationOptions where you can pass only the message to send and this method will be send to all users, of if you want you can pass a kind of target for specify the users
I hope this help you
For more info check these links:
Tutorial: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/notifications/push-notifications-overview/push-notifications-in-hybrid-applications/tag-based-notifications-in-hybrid-applications/
Documentation: http://www-01.ibm.com/support/knowledgecenter/api/content/nl/es/SSZH4A_6.2.0/com.ibm.worklight.apiref.doc/html/refjavascript-server/html/WL.Server.html#sendMessage

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