XMPPFramework for iPhone is powerful. Everything works for me, but how to keep the connection in the background for more than 10 minutes? I would appreciate additional documentation / instructions on how to do this.
So, the use case is simple and common: Joe online and in the iPhone app. He leaves the chat application and goes to Safari, plays the game, broadcasts the movie and does other things for 3 hours (or more). Joe wants to continue to receive messages during this time.
The sample application allows Joe to receive local notifications in the background, but only 10 minutes. Here is the relevant code (I think). Thanks!
To help other people even get to this, you need the xmppstream enableBackgroundingSocket property for YES (this is done for you in the iphoneXMPP example project that you must copy) and in appname-info.plist (i.e., iosChat-info-plist ) you need to add a new key / value pair. You must right-click and "add row". You must select “required background modes” for the key, and then enter “voip”. Xcode will detect that you mean that the “application provides voice over IP services” after pressing the enter key. This will make you 10 minutes to keep the chat application open in the background (I think). But we want endlessly, and I suspect that the answer lies in the method below. Do I just have to "reconnect" to this method or something else like [self connect] (do I have a connection method)?
- (void)applicationDidEnterBackground:(UIApplication *)application{ DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); if ([application respondsToSelector:@selector(setKeepAliveTimeout:handler:)]) { [application setKeepAliveTimeout:600 handler:^{ DDLogVerbose(@"KeepAliveHandler"); // Do other keep alive stuff here. }]; }}
ios iphone background connection xmpp
user798719
source share