0

Server: Pusher gem(rails) Client: Pusher Swift

How do I detect if the client is gone offline(app in background) or come back online(app in foreground) using Pusher gem?

What I want to achieve is sending APN to the client, when the client enters background without querying client online flag(s).

Is it possible to achieve this? Is there way to check the status of Event trigger if the message was received by client or not?

Thanks

Bist S
  • 41
  • 1
  • 1
  • 4

1 Answers1

0

There are a few ways you can achieve what you're trying to do.

If you're using a single channel per client you can use the channel_existence webhooks as described here. As each channel is limited to a single user, you will receive a channel_vacated webhook whenever your client goes offline and a channel_occupied webhook whenever your client comes online.

If you're not using a single channel per client, you could usepresence channels and webhooks. You can configure a member_added/member_removed webhook every time a user joins/leaves a channel. There is an additional message overhead associated with this, as each user in the channel will also receive a member_added/member_removed webhook over the websocket connection.

leesio
  • 731
  • 3
  • 13
  • Hey there, I don't think the channel gets disconnected when the client's app goes in the background. And I noticed from the Pusher debug console that, if the client locks his device(iPhone) only then channel gets disconnected, which will help me to send APN, but the problem still remains when the app is in background. – Bist S Jul 14 '17 at 11:33
  • Sorry, in your question you said "offline", so I assumed you meant you wanted to know when the websocket is disconnected. – leesio Jul 17 '17 at 20:32