Is there a way for the server to push data to an app without using push notifications?
Asked Answered
V

1

5

I'm looking for a way to push data to an app similar to APNs but that doesn't use APNs. Is there a way to do this? The reason I want to do this is if the User disables notifications I want to still be able to send data to the app without needing user input such as a pull to refresh or what have you. I only want it to happen when the App is in the foreground.

Basically, I want it to use push notifications like normal, so if there is new data available the user is notified if the app is closed so the user can click on it and have the app open and display the new info. Then if the user disables push notifications through the settings the user will no longer receive notifications, but the app will still refresh if there is new data available.

I tried using GCM/FCM but that just piggybacks off of APNs so it won't work if the setting is turned off for notifications.

Is this even possible?

Viki answered 1/6, 2016 at 19:2 Comment(0)
T
8

If the app is in the foreground, you have two options:

1) Poll - For example, every few seconds to you make a network call to poll for new data. This may be possible if you can guess a frequency at which you get new data. But as you can imagine, this is pretty impractical/wasteful if you have to do this very often.

2) Push - You can open a persistent HTTP connection (web socket) and push new data to the client from server. This is more difficult architecture (publish-subscribe) to implement than polling, but definitely worth the time if you implementing any sort of real time system (think new Facebook posts on the timeline, new tweets). For websockets, you can use a home grown solution (eg http://socket.io/) or you can use many available 3rd party solutions (like http://pubnub.com etc.)

Thi answered 1/6, 2016 at 19:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.