I am Working On XMPP. I want to get notification in background mode. And I implement this things also ,
- (void)xmppStream:(XMPPStream *)sender socketWillConnect:(GCDAsyncSocket *)socket
{
// Tell the socket to stay around if the app goes to the background (only works on apps with the VoIP background flag set)
[socket performBlock:^{
[socket enableBackgroundingOnSocket];
}];
}
in my code i set VOIP flag in background modes of app plist file. In this mode my app can run in the background completely. But apple reject that way.
So. i think other way is APNS(Push Notification) but In my app huge chatting users then how can handle messges using Push Notification ?
And one more thing can i set silent audio file play in background mode and set background mode working ? in this way any problem or regection problem from apple side ?
So, Give Me some proper idea and suggestion For this Question.
Thank x in Advance.
how can handle messages using Push Notification ?
You need to check if user is connected to XMPP server or not. If user is connected to XMPP go ahead via XMPP messaging , if user is not connected to XMPP , send push notification that will help user to appear online and receive messages.
And one more thing can i set silent audio file play in background mode and set background mode working ? in this way any problem or rejection problem from apple side ?
Yes apple will reject app (Intended to cheat Apple )
And one more thing can i set silent audio file play in background mode and set background mode working ? in this way any problem or rejection problem from apple side ?
This way Apple is rejecting App.
To notify use about the received message you have to use local notification for background and foreground state of App and use push notification for not running state of App.
To achieve your purpose use any background mode is not the solution.
When your app background / kill, that time send webservice to server which can tell - you are offline.
Then after sever can send you Push notification all chat content.