I am building an iOS app based on XMPP. When I send an XMPP message from a client via XMPPFramework, I found the message of the delegate called instantly.
- (void)xmppStream:(XMPPStream *)sender didSendMessage:(XMPPMessage *)message
But my message contains lots of data, I am sure it cannot be sent so fast. Then the user puts the app to background, and the message is lost. How can I solve this problem?
It seems that
is called instantly, true, but:
You can request up to 10 minutes of time if your application has entered background state to ensure that your request finishes:
Article about the background states: http://www.macworld.com/article/1164616/how_ios_multitasking_really_works.html
Apple Docs: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
The XMPPStream has a property enableBackgroundingOnSocket which you can set to YES:
Note that you can run into issues with the App Store, when using this trick to “fake” the voip background mode as discussed here:
iphone XMPP App run background