Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift and ios background #7

Closed
gcmartijn opened this issue Nov 13, 2014 · 1 comment
Closed

swift and ios background #7

gcmartijn opened this issue Nov 13, 2014 · 1 comment
Assignees
Labels

Comments

@gcmartijn
Copy link

I'm testing swift at the moment, and therefore I can't use your code :(
(or maybe I can, but don't know how haha)

That's why i'm using https://github.com/daltoniam/Starscream/blob/master/examples/SimpleTest/SimpleTest/ViewController.swift
and a nodejs primus server with faye.

Everything is working, except for one thing.
Keeping the connection open when the app is on the background (the user is at the home screen)

I want to keep it open, so I can send a notification or something else to it.
Do you have the same problem ?
Or can you send messages to it, when the app is in the background ?

@nunofgs nunofgs self-assigned this Nov 13, 2014
@nunofgs
Copy link
Contributor

nunofgs commented Nov 13, 2014

Hi!

I've implemented support in Primus-Objc for background connectivity successfully. This is already handled for you but, in your case, you'll have to implement it yourself since you're using a WebSocket library directly.

You will need to enable VOIP for background usage in our app's plist. You can then hand off your TCP connection to the system by implementing the -stream:handleEvent: method.

The trick is that iOS only gives you CPU time every 10 minutes or so (that's the minimum you can ask from the OS). When that happens, you need to the send a heartbeat to the primus server so that it doesn't kill your connection.

For this to work, you will also need to configure your primus server with a 10-minute timeout, as described here.

@nunofgs nunofgs closed this as completed Nov 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants