Is there a way to find if the iOS app is in background from Pusher Gem?

267 Views Asked by At

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

1

There are 1 best solutions below

2
leesio On

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.