Worklight: Push notification without User ID

后端 未结 3 2235
轮回少年
轮回少年 2020-12-06 21:12

Kindly suggest, is it possible to send push notification without having user ID ? Lets say we want to send push messages to all users who have downloaded our App. OR due to

3条回答
  •  难免孤独
    2020-12-06 22:09

    One way or another, you need a way to identify the user. It will come down to what you consider to be a 'userID'. There is a way to distinguish between users without using a permanent userID. You can use the persistent cookie realm. If you add this to your authenticationConfig.xml file:

           
                com.worklight.core.auth.ext.PersistentCookieAuthenticator
            
    

    Then a unique ID based on a persistent cookie will be created for the user when they connect to the worklight server:

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

    No further interaction is required by the user or the developer. Simply adding the class to authenticationConfig.xml is enough to generate the userID.

    You can use this cookie to subscribe a user for push notifications. If for security reasons you wish to no longer have this user identified by this persistentCookieID, then you can simply clear the cookies on the application and a new ID will be generated for the user. They will then need to resubscribe for push notifications if a new persistentCookieID is generated.

提交回复
热议问题