Trying to send Push Notification based on DEVICE_ID, In MFP 8 Console, My device ID is showing under DEVICES section but if i try to send notification, Console throws error as "An error occurred while the notification was sent. Internal server error. No devices found."
Scope - push.mobileclient
Initialize, isPushSupported and then RegisterDevice is triggered and in logs, it shown the token as well. how to resolve ?
Device registration showing up in the Devices console does not mean that push registration is successful. Even if push registration is complete, it will depend entirely on the application logic that there is a user identity associated with the subscription.
When you attempt to send notification by userid and it says "No devices found", this means that there are no subscriptions against this userid. It is possible there is no subscription at all , or the subscriptions have been made against a different user - or even anonymous user.
Use get push registrations and get push subscriptions REST calls to verify your current registration and subscription. If these are with anonymous user identity verify your scope -> security check mapping and your application logic.
Related
I'm doing analysis on Firebase Token and understood below points:-
-> A Firebase token is saved in database which will be used for sending notifications.
-> The token generally do not expire except in the following cases:
- The app deletes Instance ID
- The app is restored on a new device
- The user uninstalls/reinstall the app
- The user clears app data.
-> When we use a token which is expired we get errors like Not Registered from the response while sending messages.
-> To avoid the error, we should be deleting the token from database.
However I have found that If we login to a cloud application (which is my app currently), a new fcm token gets generated when i logged in to a new browser say FireFox, Edge etc.
So, the token is generated based on browser or System IP or what exactly the Fcm uses to generate a token ?
The method used to generate the token is an implementation detail, and you should not depend on that to build your app.
A token uniquely identifies a device. Each device receives messages independently of each other, and does not know anything about the user of that device. It's expected that if a user signed into an app on multiple devices, that each device would generate a unique token. If you want to send message to a user, you will have to map each of the user's device tokens in your own database, and send the message to each of them, or only the ones that the user chooses.
You can expect that device tokens might change over time. If you send a message to a device, and the API tells you that the token is not valid, you should simply delete it from your records.
Using MFP 8, Related to PUSH NOTIFICATION and USERLOGIN Security check, If i register a device, I can see in MFP CONSOLE (DEVICE SECTION) and PUSH_DEVICES Table as well.
In PUSH_DEVICES table (UserId is anonymous) and phonenumber is empty.
How to update these 2 from app (NOT BY REST SERVICE) ?
if the userid is anonymous, i cannot see the USERID and DISPLAY NAME in DEVICES Section of MFP CONSOLE as well
Push device registration and subscription takes an independent path. These steps have to be done separately.
However, the user identity assigned against Push device registration and subscription flows from identity created using the securitycheck that maps to "push.mobileclient".
If you see "anonymous" user against your push registration, this normally happens when you make the push registration when an identity has not already been established with the secuirtycheck.
Verify your application code flow and ensure you do MFPPush.registerDevice() only after authentication is complete. You can use network traffic analysis to understand your current sequence.
In an application I am building, it is possible for a logged in user to receive specific push notifications related to activity their user account is participating in or subscribing to.
As it stands at the moment, if a user logs out, they remain subscribed and the service worker remains registered.
However, it would mean that push notifications they've subscribed to will still be received.
On the plus side, however, it means that if the original user logs in again, they won't need to go to their preferences and re-enable notifications and re-register a new service worker/subscription.
Does anyone have any examples of how to approach this in a secure way so notifications are not leaked after logging out, but maintaining the existing subscription in case they log back in? Is it even possible?
Thanks,
P
Usually you have an endpoint in your database associated to a user ID, so that you can target that user with push notifications.
When the user logs out you can simply remove the association between the endpoint and the user ID in your database.
We have one device group per user for our mobile app. When a new user sign up, a new device group with registration token is created via create operation from app server and its notification key is stored with user data.
When a user sign out of the app, its registration token is removed from the notification key via remove operation as we don't want to send personal notification for that user to that device anymore. This step returns same notification key.
When a user sign in again, we try to add the registration token via add operation using the stored notification key. This action returns 400 (Bad Request) status from Firebase server.
Is this expected behavior? If so, how to handle the above use-case?
Notification key for a device group is removed as soon as the token count reaches zero.
I ended up using topics instead of device groups for this use case.
We are developing hybrid mobile application in IBM MobileFirst V7.1,Java 1.7v.
In this application we are developed push notification using Adapter Based Authentication.
In our application we are sending push notification using Adapter based Authentication.
The notification is delivered based on userId.
Here for first time to a particular userId,I'm able to send notification.
After that when user trying with another userId I'm unable to send notification,getting an error "user already exist please logout".
Error in Log:
Cannot change identity of an already logged in user in realm 'pushAppRealm'. The application must logout first.
for this in client side I'm checking whether user is authenticated or not by using "WL.Client.isUserAuthenticated(realm)" ,it is always retuning false.
I also tried with logout option when user clicks on login button I'm logging out the user and again authenticating the user -
here also I'm facing same issue "user already exist please logout".
Push notifications should be dispatched from the server , not from the client.
In your flow, the very first time you authenticate , you will assign a user identity into your user realm. Now from the client , you invoke the adapter procedure that sends out the notification.
The second time around , you pass another userid. This time you try to authenticate again with the another user (all within the same session). It amounts to forcing a new identity when the realm already has one.
This is why you see message in the server that says - "Cannot change identity of an already logged in user in realm 'pushAppRealm'. The application must logout first."
The right approach to be adopted is :
Authenticate into the realm.
Subscribe for Push. This assigns the user identity from 1) to your subscription.
Either use poll mechanism or REST API calls to dispatch notification. Pass the userids as arguments in the REST calls.