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 Answers
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:
userSubscription = WL.Server.getUserNotificationSubscription ("MyEventSource", userID);
var notification = WL.Server.createDefaultNotification("Hello");
var delayTimeout = WL.Server.notifyDevice( userSubscription, userSubscription.getDeviceSubscriptions()[0].token, notification);
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.