My iPhone application is based on remote desktop protocol which communcates with PC using socket programming. Everything works fine in iOS4, but now i encounter an issue with iOS5 based device.
My socket get's disconnected when user presses lock button in iOS5 based devices. I have developed a cocoa based static socket library which does all communication for my iphone app.
FYI: I just call a function exposed from my library to start the communication. I call it as a background thread using
[self performSelectorInBackGround:#selector(triggerCommunication:) withObject:IP_Address];
a. Why does the socket disconnects on pressing lock button in iOS5 ?
b. Is there a way to prevent the socket from not being disconnect?
Thanks,
If we compile with iOS5 SDK, and run application, then socket disconnects on clicking lock button.
I recompiled my application with iOS4 SDK and tested my application on iOS5 based iPhone. And now socket didnot disconnect even after locking!.
Thanks
Related
I would like to ask you just some initial directions on how to send/receive (essentially receive) some data to/from a bluetooth 2.0 device. I'm trying CoreBluetooth Framework api with no success.
At the same time, I'm sure the connection can be done due to the fact the the device is already paired within iphone 5s and it works correctly (when an incoming call arrived, by pressing the button on the device the call is opened on the iphone).
Then in particular I need to programmatically intercept (on my app) the button pressing on the device. Could you send me some helps on that?
Thank you very much.
is it possible to create an iphone-app, which can communicate with other iphones (with the app installed) even if the app is running in the background or the iphone is locked (=standby).
there is an app called "Bluetooth", which establishes a connection, but looses it as soon as the app is closed or the iphone in standby.
hope i am not too confusing in my explanations
I've a problem working with GameKit and GKSession operations.
I'm trying to implement a GKSession client-server iOS app system (ServerApp, ClientApp) having this behavior:
ServerApp creates a GKSession in GKSessionModeServer mode (Bluetooth only)
ClientApp detects the server and connects to it
Some data exchange between apps and stuff
Everything is going fine except when ServerApp or ClientApp instance goes to background.
If ServerApp goes to background, Client receives a GKPeerStateUnavailable event and i can't connect to it. What I need is to avoid this event: that means, find a way to keep ServerApp GKSession socket going even when app is in background.
Any help will be appreciated.
Perhaps you could keep the app running in the background by setting the info.plist flag to keep it alive like a music player?
This thread talks about this:
From Raaz
My online app runs on iPhone-3GS iOS 4.3, use NSStream to communicate with server.
When I minimize the app, lock phone, and relaunch my app the streams will end.
So my app loses connection to server.
Anyone knows how to keep the connection after locking phone? Is it a feature of iOS multitask?
This is a feature of iOS. Networking connections of backgrounded apps are cut off. You need to request "VoIP" treatment: for this, you need to set the "voip" value for the Info.plist key UIBackgroundModes and then mark your socket as being a VoIP socket setting the kCFStreamNetworkServiceType of your socket to kCFStreamNetworkServiceTypeVoIP using CFReadStreamSetProperty.
See also the Apple iOS App Programming Guide, section Tips for Developing a VoIP App.
I'm using a VOiP Socket in my iPhone application. I manage to get it working properly, both in background mode, or when the application is in the foreground.
My issue is at iPhone startup: how to be sure that the iPhone has network access (3G or wifi) in order to properly connect the socket without bothering the user ?
Details: a VOiP application is supposed to be started automatically as soon as the iPhone starts : this is working ok, the didFinishLaunching is invoked right after the iPhone startups. But at this time, the user may not have entered his pin code (so that 3G isn't available) and wifi may not be available.
Is there any technique to start automatically the VOiP Socket when network access is ok ?
My current approach that fails : in the didFinishLaunching I keep on trying to start the VOiP socket every 5 secs. If it takes too long without managing to get the connection, the OS is going to kill the app, (max 20s to start), but as the app is flagged as "VOiP", it's going to be started again, and so on...
After a while, once network is OK, the socket is being created , connected and everything seems to works ok, EXCEPT that when data comes to the socket, my callback didReceivedData is not invoked (I display a local notification as soon as I get something from the socket for debug purpose) .
Then, if I start the application just 1 time, and then quit it (home button), so that the application is put in the background, in that case, the socket callback is properly invoked and I see local notifications being displayed, proof that the socket is properly waken up in that case.
I would like to get the VOiP socket up and running right from iPhone startup (once network is OK) without having the user to launch the application 1 time. Any idea about how to achieve this ?
Use the Reachability class to poll for connectivity every X seconds, THEN try to connect.
Reachability won't take as long as creating the VoIP socket will.