我正在开发一款聊天应用。
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message{}
当App is Background
时,此方法有效并在模拟器中运行时捕获购买断点但在 Real Device App 中的应用程序中运行时
background mode . its not working in background mode
最佳答案
添加以下代码
UIBackgroundTaskIdentifier bgTask = 0;
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
在你的
- (void)applicationDidEnterBackground:(UIApplication *)application
然后这个方法
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message{}
也将在后台工作。
有关 BackgroundTask 的更多信息,请访问 Documentation
关于ios - didReceiveMessage :(XMPPMessage *)message Not Running Actual Device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39020100/