1 Reply
      Latest reply on Feb 6, 2017 3:15 PM by eskimo
      Franky123 Level 1 Level 1 (0 points)

        Hi guys,


        When the iOS app is not used for over 24 hours and we want to resume the app from suspended state, we basically cannot login the user.


        Question 1: How can I properly test this scenario from "suspended state"? I have tried several approaches mentioned on forums like: "press the home button, and open a lot of other apps to push it in suspended state". But this doesn't give the same behaviour. I cannot replicate the issue like that.


        We basically want the user to auto-login using his token with AFNetworking library. This normally works just fine, but when the app resumes from suspended state it doesn't. Hope you can give me some useful tips here.



        • Re: iOS app network connectivity from suspended state
          eskimo Apple Staff Apple Staff (13,325 points)

          From the suspended state?  Or from the terminated state?  The former will require a resume while the latter will require a relaunch.  Each presents its own unique challenges.

          Getting the app suspended is quite easy: put it in the background and wait for a minute.  As long as it doesn’t have any reason to stay running in the background, it’ll suspend promptly.

          Getting an app into the terminated state is also easily, albeit a bit tedious.  All you need to do is restart the device.  Unless the app is tied some specific background features (like VoIP), it won’t be relaunched on restart.

          IMPORTANT Do not terminate the app via the multitasking.  In most cases the system will interpret that gesture as a request from the user to not allow the app to run in the background, and that’s state only gets cleared when the user manually launches the app.

          In terms of forcing the app to be resumed (or relaunched) in the background, you have a bunch of options.  Personally, I vacillate between:

          • Silent push notification

          • Beacon region monitoring (using another iOS device as the beacon)

          Finally, a common problem with things failing when run in the background is data protection, both with keychain items and the files in the file system.  You need to make sure the protection class on the items you access is compatible with your background execution strategy.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"