Vote count:
0
Problem
As the title says, I'm currently experiencing an issue where the NSHTTPCookieStorage is loosing the cookies for our app when it's initialised in background before the phone has been unlocked at least once after a reboot.
Once the cookies are lost, they can't be recovered in any way, forcing the user to re login to retrieve a new set of cookies and recover a session.
If app activity is registered for the first time AFTER the user has unlocked her/his phone, then everything works like a charm.
Context:
This issue happened to us using NSURLRequest and NSURLSession as well as using ASIHTTP and AFNetworking with automatic cookie handling, so we came to the conclusion its affecting the whole NSHTTPCookieStorage class.
Our app has SLC (Significant Location Change monitoring) so its
triggered in background automatically.
Steps to reproduce
- Make a demo app that performs a network call ("Lets call it CALL A"), to authenticate to a server, getting some cookies in response to that.
- Perform a second call (Lets call it "CALL B") that requires this cookies to be sent in order to work. If everything goes well, cookies should be automatically managed and sent to the server accordingly.
- Make your demo app be able to execute some background stuff, for example enable SLC monitoring. In the execution of this background behaviour perform "CALL B" again (If it's inside a background task or not doesn't really matter for the test purpose)
- Reboot your phone and DON'T unlock it.
Wait until the SLC, or the background behaviour you chose is triggered and CALL B is done.
TIP: You can disable and enable Airplane mode to force an SLC trigger on the device.
Problem: If in that time a significant location change is triggered, the app comes to live on background but the NSUserDefaults is empty (Only has some keys from apple but none of our custom keys). Then, the NSUserDefaults never gets this keys recovered no matter what you do (e.g. if you unlock your phone and open the app you will see the keys are still missing).
Any help or idea will be appreciated.
Aucun commentaire:
Enregistrer un commentaire