0
votes

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".

1
What is the actual error you're getting. - Idan Adar
We are able to send notification for first time, second time we are unable to get it. Authentication is getting false for second time. - VK Chikkadamalla
What is "false"? what is the error you get in your logs? - Idan Adar
You are able to send notification first time, second time you are unable to get it? What does that mean? The second time, are you able to send the notification ? What does it mean, when you say - "after user logout also notification has to be sent"? Notification is dispatched from the server. What does user logout have to do with it? - Vivin K
i modified the question - VK Chikkadamalla

1 Answers

0
votes

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 :

  1. Authenticate into the realm.
  2. Subscribe for Push. This assigns the user identity from 1) to your subscription.
  3. Either use poll mechanism or REST API calls to dispatch notification. Pass the userids as arguments in the REST calls.