工作灯:推送没有用户ID的通知

时间:2013-12-12 11:58:58

标签: push-notification ibm-mobilefirst

请建议,是否可以在没有用户ID的情况下发送推送通知?假设我们希望向已下载应用程序的所有用户发送推送消息。或者由于安全原因,用户ID无法存储在数据库中(或在应用程序中使用)。

3 个答案:

答案 0 :(得分:2)

无论如何,您需要一种识别用户的方法。它将归结为您认为是'userID'的内容。有一种方法可以在不使用永久用户ID的情况下区分用户。您可以使用持久性cookie领域。如果将其添加到authenticationConfig.xml文件中:

       <realm name="PersistentCookie" loginModule="WeakDummy">
            <className>com.worklight.core.auth.ext.PersistentCookieAuthenticator</className>
        </realm>

然后,当用户连接到worklight服务器时,将为用户创建基于持久性cookie的唯一ID:

"PersistentCookie":{"userId":"6410a0f9-98fb-4940-a127-da940c5d7e16","attributes":{},"isUserAuthenticated":1,"displayName":"6410a0f9-98fb-4940-a127-da940c5d7e16"}

用户或开发者无需进一步交互。只需将该类添加到authenticationConfig.xml即可生成userID。

您可以使用此Cookie为订阅者订阅推送通知。如果出于安全原因,您希望不再使用此persistentCookieID标识此用户,则只需清除应用程序上的cookie,即可为该用户生成新ID。如果生成新的persistentCookieID,他们将需要重新订阅推送通知。

答案 1 :(得分:0)

您需要在Worklight中发送推送通知的订阅列表以及适配器(服务器)端API以获取所有订阅

WL.Server.getUserNotificationSubscription(eventSource, userId);

因此,如果没有userId,则无法发送推送通知。

我不确定安全问题,因为userID只是用于登录应用程序的用户名。如果您的应用和事件源都有securityTests,那么Worklight会自动保存订阅和userId。

答案 2 :(得分:0)

从Worklight 6.2开始,您可以使用“广播通知”功能向所有用户(已订阅或未订阅)发送通知。

有关详细信息,请参阅http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/c_push_notif_broadcast.html

要发送广播通知,您可以使用WL.Server.sendMessage(applicationId,notificationOptions)。更多信息可以在 http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/c_send_push_notifications.html

相关问题