Вопрос

In my iOS application, I need to notify user about some emergency events on a remote device. It's required that user get alerts regardless of the app state: if the app if in foreground, background modes, or even killed.

According to the Apple docs, only "voip" backrground mode allows "keep alive" functionality to stay connected to the server while being in background. But "voip" mode is allowed only for real VoIP apps, and my app does not provide any VoiP services. So, I suppose the only option for my case is using of Apple push notifications.

Push notifications can't be delivered while the user's iOS device lost an Internet connection. But if the connection has been lost user doesn't know this until he checks his device manually. So while being offline, he can't receive any push notifications, and will not know about it until he checked his phone state.

My question is: is there any way to notify user when Internet is disconnected on iOS device and push notifications service is unavailable to inform user that he'll not get any notifications while he's offline?

Это было полезно?

Решение

Be clear what you're asking here. Just because your device has an internet connection locally, it doesn't mean that it has a connection to a server - yours or Apple's. You can test for a connection to a server by maintaining a keep-alive system in your app, but think what that will do for the battery life.

If you need to be sure a message will reach the device even when its internet connection is down, or if your application is 'killed' (your words) you'll need to adopt a different approach.

Send an SMS message.

Другие советы

There are 4 channels from the world to device available:

  • Internet connection to your server - unavailable;
  • Push-notification - unavailable;
  • SMS-message - got it!
  • Local push-notifications (if you could predict events times in future).
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top