简体   繁体   中英

Can't make a network call from background notification after app force-quit and phone restart

I am using background notifications in my app. And I use it to make a small call to our server after each notification. Tested on iPhone 5/6 and iOS 11

In those cases I am able to call the server to mark my notification as received :

  • the app is in foreground
  • the app is in background
  • I just reboot my device

But sometimes users kill the app and then I can not call my server, that is a normal behaviour of background notification.

BUT, from the documentation :

However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

Source : https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application

So if I am correct, if I force quit the app and then restart my device I should be able to make a network call again after phone restart.

This is my issue, it does not work. After a force quit of my app and a phone restart the notification is displayed on the screen of the phone but the network call is not done.

Do you have the same issue ? Do you know a solution ?

Your application has to be in the multitasking stack to make a call to server when notification is received. That is, application has to opened atleast once after the reboot to meet your expectation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM