问题描述
我想获取当前订阅的设备ID?我如何在客户端或服务器端获取它?
I want to get the currently subscribed device ID ? how i can get it on the client side or on the server side?
我知道订阅表,但我不想从中获取。
I know the subscription table, but i donn't want to get from it.
其次,如果一个用户已经订阅了两个设备,现在他/她正在订阅第三个设备,我想要捕获第三个(当前)设备ID。
Secondly, if one user has already subscribed two devices and now he/she is subscribing third device, i want to capture the third (current) device ID.
稍后,我必须在我的另一张表中保存第三个设备ID。
Later, I have to save that third device Id in my another table.
如果无法识别目前订阅设备,然后如果我去订阅表,那我怎么知道这个设备ID是新注册的设备ID?
If there is no way to identify the currently subscribed device , then if i go to subscription table, then how i get know that "this device ID is the newly registered device ID ? "
希望它会很清楚。
谢谢
推荐答案
-
在适配器中注册事件源时,您可以指定onUserSubscribe回调。一旦用户订阅推送通知,就会调用此回调。调用后,此回调将接收用户订阅对象作为参数。该对象包含userId和deviceId。
When registering event source in adapter you can specify onUserSubscribe callback. This callback will be invoked once user subscribes to push notifications. Once invoked this callback will receive user subscription object as a parameter. This object contains both userId and deviceId.
WL.Server.getUserNotificationSubscription(event-source,userId)将返回带有设备订阅数组的用户订阅对象。每个设备订阅对象都有deviceId。
WL.Server.getUserNotificationSubscription("event-source","userId") will return user subscription object with an array of device subscriptions. Each device subscription object will have deviceId.
在客户端,deviceId是设备认证领域的userId。例如。如果您不使用配置,您可以使用WL.Client.getUserInfo(wl_deviceNoProvisioningRealm,userId)获取deviceId;
On a client side deviceId is a userId of device authentication realm. E.g. in case you use no provisioning you can get deviceId by using WL.Client.getUserInfo("wl_deviceNoProvisioningRealm", "userId");
服务器端没有知道你的当前设备。您可以使用onUserSubscribe回调将特定设备标记为最新。
Server side doesn't know your "current" device. You can use onUserSubscribe callback to mark specific device as latest.
用户订阅对象可以拥有自定义属性,您可以使用它们来维护订阅状态。
user subscription object can have custom properties, you can use them to maintain subscription state.
这篇关于Worklight:如何获取Push订阅的当前设备ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!