Pergunta

I want to create an application which have 2 modes: non-logged-in and logged-in (having username).

I want to send push notifications to devices in both modes. The non-logged-in devices should receive notifications such as general announcements, new events, etc. The logged-in mode devices will also receive same notifications and few more.

Now what I want to do is to subscribe the device to receive notifications for non-logged-in mode then once the user logs in to his account from that device I want to unsubscribe the previous non-logged-in notifications.

I've read the answer to this question : Worklight: Push notification without User ID I think that I can play with onUserSubscribe callback when registering the user and unsubscribe the userId of the persistent cookie. Is this a good idea ? Is there another suggestion ?

Foi útil?

Solução

My thinking is that you could register an app to 2 event sources.

  • The first event source will handle the general notifications that an app should receive, whether a user is logged-in or not.
  • The second event source will handle the notifications for logged-in users.

When the app launches, subscribe to the first event source.
When the user decides to log-in, subscribe to the second event.

You should allow the user to unsubscribe from both if s/he so chooses, as well.

Additional information:

Outras dicas

So what you're trying to achieve is push notifications broadcast (send to all users). This is something that you'll be able to do with upcoming Worklight 6.2 release. You will not have to subscribe users according to username, but will be able to specify tags during subscription. And after that you'll be able to send push notifications according to this tags.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top