简体   繁体   中英

Send local Notification in background in XMPP Framework

I am doing a chat Application in IOS using XMPP Framework . Previously it was not working in background but now i need to send local notification when user receive a message . My app don't use push notification for this feature because in same app in android device is sending local notification when user receive a message.

I have tried some docs over internet and found that app will not support in background and i need to check VOIP in back ground mode , but docs also said that there is a chance to reject the app by apple .

Here is my code for that :

- (void)applicationDidEnterBackground:(UIApplication *)application{

 XMPPPresence * presence =[XMPPPresence presence];  
[[self xmppStream] sendElement:presence];
NSLog(@"*********%@",presence.type);}  

but - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message{}

is not calling in background I have also enable enableBackgroundingOnSocket. But i need to know that why it is not working in background . and if Apple reject this App because of VOIP is there alternative solution for that without push notification .

Any guidance or suggestion will be helpful.

When your app goes in background you (the client) close the connection with the xmpp server. When your app comes back into foreground you reopen the connection. If your server need to send messages to your client, it must use push notifications. When the client receives the notification CAN (it depends on the user action) can back to foreground. Only for VoIP apps You need to specify the voip UIBackgroundMode in your Info.plist. info.plist file : 1 - set "Application does not run in background" to NO. 2 - added "App provides Voice over IP services" to "Required background modes" 3 - xmppStream.enableBackgroundingOnSocket = YES

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM