getUserNotificationSubscription WORKLIGHT推送通知中的userID [英] userID in getUserNotificationSubscription WORKLIGHT Pushnotification

查看:167
本文介绍了getUserNotificationSubscription WORKLIGHT推送通知中的userID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在IBM worklight项目中实现推送通知。 developerworks中的示例代码使用一些身份验证挑战程序机制来执行订阅。我以某种方式使用相同的身份验证挑战来进行订阅(尽管我的应用程序设计不需要这样做)。在示例代码中,不写入通知调用的实际触发器。

I am implementing push notification in my IBM worklight project. Sample code in developerworks do it with some authentication challenger mechanism to do the subscription. I somehow used the same Authentication challenge to do the subscription (although my app design doesn't need to do this). In the sample code actual trigger of notification call is not written.

我从网络资源中发现需要使用WL.Server.getUserNotificationSubscription(eventSourceName,userId)来获取订阅的用户详细信息。但是我不知道如何获取userId详细信息?请告诉我这里的userId以及如何获取它的价值。

I found out from web resource that WL.Server.getUserNotificationSubscription(eventSourceName, userId) need to be used to get the subscribed user details. However I don't know how to get userId details here? Please let me know what is userId here and how to get its value.

推荐答案

以下是有关的信息WL.Server.getUserNotificationSubscripion


getUserNotificationSubscription:

getUserNotificationSubscription(eventSource,userId)返回用户的
订阅对象。返回具有指定ID的
用户的订阅对象到指定的事件源。

getUserNotificationSubscription(eventSource, userId) Returns a subscription object for a user. Returns a subscription object for the user with the specified ID to the specified event source.

参数:
eventSource - 必需。包含事件源名称的字符串。
userId - 强制性。包含在登录过程中创建的用户标识的字符串。可以通过调用
WL.Server.getActiveUser来获取用户ID。

Parameters: eventSource - Mandatory. A string containing the name of the event source. userId - Mandatory. A string containing the user ID, created during the login process. The user ID can be obtained by calling WL.Server.getActiveUser.

返回:
该方法返回一个包含用户ID和可变订阅状态的订阅对象。
示例:{userId:'bjones',state:{numCoupons:3}}

Returns: The method returns a subscription object that contains the user ID and the mutable subscription state. Example: {userId: 'bjones', state: {numCoupons: 3}}

注意:
所有订阅对象字段都是只读的,用户订阅状态除外。您可以在
JavaScript代码中修改用户订阅状态,然后必须使用save方法将其保存到$ b $bIBM®Worklight®数据库。

Note: All subscription object fields are read-only, except for the user subscription state. You can modify the user subscription state in your JavaScript code, and then must use the save method to save it to the IBM® Worklight® database.

如您所见,userId是在登录和身份验证过程中创建的特定用户。 Worklight提供了一个服务器端API WL.Server.getActiveUser(),它允许您检索当前用户。

As you can see the userId is the specific user that was created during the login and authentication process. Worklight provides a server side API WL.Server.getActiveUser() which allows you to retrieve the current user.

关于您的其他声明说在示例代码中实际没有写入通知调用的触发器。Worklight实际上在示例项目中提供了一个jar文件,允许您触发通知。以下是此后端仿真的更多信息:

In regards to your other statement saying "in the sample code actual trigger of notification call is not written. " Worklight actually provides a jar file inside of the sample project that allows you to trigger the notification. Here is some more information for this backend emulation:

如果您有任何其他问题,请与我们联系。

Let me know if you have any further questions.

这篇关于getUserNotificationSubscription WORKLIGHT推送通知中的userID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆