For applications that use socket communication, it is often desirable for the app to be in the background for network communication, which is allowed by default in IOS8 and later versions, and the socket can be run directly in the background, but not for versions prior to iOS8. Two-step setup is required to allow the socket to run in the background.
Here, for example, in the case of XMPP sockets, the following two steps are required in order to send push notifications after receiving a message in the background:
① Open Info.plist, add the following key-value pairs:
Required Background modes = APP provides Voice over IP services
② configuration Xmppstream The Enablebackgroundingonsocket property is yes:
_xmppstream.enablebackgroundingonsocket = YES;
It should be noted that in the IOS7 simulator, this setup is still unable to implement the socket background operation, this is the emulator bug, on the real machine can be implemented.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
(74) How to make the socket run in the background before iOS8