It seems that
- (void)xmppStream:(XMPPStream *)sender didSendMessage:(XMPPMessage *)message;
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:
/**
* If set, the kCFStreamNetworkServiceTypeVoIP flags will be set on the underlying CFRead/Write streams.
*
* The default value is NO.
**/
@property (readwrite, assign) BOOL enableBackgroundingOnSocket;
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