Topic
  • 4 replies
  • Latest Post - ‏2012-10-29T02:49:35Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic Can we notify all online users

‏2012-10-25T09:13:10Z |
Hi,

I just tried push notification, I can post message and received it from GCM.
Now I checked developer reference, I don't found a method used to retrieve all online users or a method just like notifyAllUsers.

When server required to post a message to all online users, i.e. server want to notify all users that server will be restarted in few minutes, is it possible?

Thanks!
Daniel
  • IdanAdar
    IdanAdar
    741 Posts

    Re: Can we notify all online users

    ‏2012-10-25T09:26:34Z  
    Define what is "online" for you.
    A user whose online at this very instant? in the past 5 minutes? with the application connected to the server? with the application in the foregound?

    What you can do is get the push event, and verify the state of the app in the client-side. If the state is what you want, then display the notification. Otherwise, don't.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Can we notify all online users

    ‏2012-10-26T02:29:43Z  
    • IdanAdar
    • ‏2012-10-25T09:26:34Z
    Define what is "online" for you.
    A user whose online at this very instant? in the past 5 minutes? with the application connected to the server? with the application in the foregound?

    What you can do is get the push event, and verify the state of the app in the client-side. If the state is what you want, then display the notification. Otherwise, don't.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    Hi IdanAdar,

    in my case online users means that that connected to server (assumes that they all logged into server) in both foreground background. if user go to home screen and open a document and want to go back to the app and input something, we also treat it as connected user, and they are expected to receive notifications.

    I know an app bring to foreground, pending notification (received when app go background) will be shown. I want to notify all connected users. How I can get all logged user ID or a convenient API to notify all users without iterating over user list?
    thanks.
    Daniel
  • AntonAleksandrov
    AntonAleksandrov
    55 Posts

    Re: Can we notify all online users

    ‏2012-10-28T09:04:03Z  
    Hello,

    Worklight does not have an API for receiving a list of online users, as this is too generic.
    You can create your own user storage/persistance layer like SQL database or a static application level Java object.
    Then you can use this to save/delete user data to keep a list of online users.
    Once again - this is completely manual.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Can we notify all online users

    ‏2012-10-29T02:49:35Z  
    Hello,

    Worklight does not have an API for receiving a list of online users, as this is too generic.
    You can create your own user storage/persistance layer like SQL database or a static application level Java object.
    Then you can use this to save/delete user data to keep a list of online users.
    Once again - this is completely manual.
    Hi,

    Thanks, I keep user id list in cache after a user logged in and remove them from cache when calling logout procedure.

    Daniel.