Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Persist session + connection timeout #7 #13

Closed
wants to merge 1 commit into from

Conversation

johnnynanjiang
Copy link

  • Persist session

Please refer to the following comments on Starscream

daltoniam/Starscream#309

I've recently had an in-depth conversation with Apple DTS on this.

Simply, you have to use PushKit/APNS. The "Legacy VOIP API" as they call it (which would hand the socket over to the system to wake up your app if communication arrived) was deprecated in iOS 9 and removed in iOS 10. As such, there's no way to keep a socket connected while in the background and that flag no longer has any effect as OP described.

You can buy yourself ~3 min by launching a background task on applicationDidEnterBackground but that's all you get and it cannot be called again without the app entering the foreground (by the user).

daltoniam/Starscream#332

The standard app lifecycle will cause the socket connection drop when entering the background. Nothing "official" can be done to prevent that. In the past people use to abuse the VOIP background mode to allow this (see #309 for more details), but Apple frowned on this as it isn't the intend use case. As that issue notes, this restriction is now strictly enforced in iOS 10. The recommend course of action is to have a server that does all the processing and wakes the app up with push notifications with the new data you need.
  • Add error handling in handleDisconnect if there is error, rename private methods to avoid confusion

@hewigovens
Copy link
Contributor

only naming changes? it doesn't match the PR title, can you move the discussion to the issue?

@hewigovens hewigovens closed this Jun 28, 2019
@hewigovens
Copy link
Contributor

Added some descriptions to #7

@johnnynanjiang
Copy link
Author

only naming changes? it doesn't match the PR title, can you move the discussion to the issue?

In addition to the naming changes, error handling was added in handleDisconnect, so that timeout error will be handled by ViewController (it is an alert in example ViewController)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants