0
votes

I've a problem regarding push notifications in worklight 6.2. When I update the os version of a device the deviceId in the worklight console table is updated. Do you know if this is a correct behaviour?

1
What is the issue? is the change in userId preventing from notifications to arriving to their destination? - Idan Adar
When an Android device updates the os version, the deviceId(No userId) in worklight console is updated(under devices tab). I notice this behaviour in server logs. Is this a correct behaviour? Another problem is that this userId expired even if the connection to the worklight server was established every day with this device. I read the documentation and the userId expired after 90 days without no connection to thr server. - AleDev
Due to this behaviour when I send a push notification from server for that device id it is rejected. - AleDev

1 Answers

0
votes

Multiple OS and hardware parameters go into generating the deviceID by Worklight SDK. This means , when there is an OS upgrade the deviceID can change.

If there are no OS changes - upgrade/reset , for the lifetime of an application, the deviceID does not change.

Also, the next time the device connects to the server ( after deviceID change) the server is updated with the new value.

It has not been mentioned if you are passing deviceID directly while dispatching the notification. If so, you should consider using the UserSubscription object to get the device id value.

For example:

notifyDevice

userSubscription = WL.Server.getUserNotificationSubscription ("MyEventSource", userID);
var notification = WL.Server.createDefaultNotification("Hello");
var delayTimeout = WL.Server.notifyDevice( userSubscription, userSubscription.getDeviceSubscriptions()[0].token, notification);

notifyDeviceSubscription

userSubscription = WL.Server.getUserNotificationSubscription ("MyEventSource", userID);
var notification = WL.Server.createDefaultNotification("Hello");
var delayTimeout = WL.Server.notifyDeviceSubscription(userSubscription.getDeviceSubscriptions()[0], notification);

This reduces the possibility of errors due to missing or wrong deviceid as subscriptions are updated when users connect to server. This way, device id stays updated at the server.