ios - didReceiveMessage :(XMPPMessage *)message Not Running Actual Device

标签 ios xmpp

我正在开发一款聊天应用。

- (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/

相关文章:

ios - 在 iOS 项目中开始使用 parse.com 的 PFLogInViewController 和 PFSignUpViewController 后出现链接器错误

ios - 当应用程序使用 Facebook 登录时,SVProgressHud 未在 iOS 9 中显示

ios - 无法在 XMPP 中获取消息传递回执

proxy - XMPP 代理 TLS 加密

mysql - 无法将 Mysql 与 Ejabberd 连接 - 无法启动应用程序 'p1_mysql'

ios - 扩展 UITextView 并触发 onChange 事件的委托(delegate)

iOS - NSOperation 中的异步 NSURLConnection

ios - Swift - 删除单个反斜杠

android - XMPP (Openfire) 推送通知 Android

xmpp - 与XMPP服务器断开连接时是否需要发送 "unavailable"类型存在?