gpt4 book ai didi

ios - VoIP 推送不适用于 iOS SDK 演示

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:02:52 24 4
gpt4 key购买 nike

我正在使用 VoIP PushKit 开发 iOS SDK。下面是接收推送通知时SDK中的代码

- (void)onReceiveMessagecontent:(NSString *)content{    
if (content && ![content isEqualToString:@""]) {
if ([[WalkieTalkie sharedWT].delegate respondsToSelector:@selector(onPushMessage:)]) {
[[WalkieTalkie sharedWT].delegate onPushMessage:content];
}
}
}

这是 SDK Demo MainViewController.m 中的代码,其中将调用委托(delegate):

- (void)onPushMessage:(NSString *)messageContent{
NSString *content = [NSString stringWithFormat:@"on recive push message: %@", messageContent];

if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"收到推送" message:content preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelButton = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:cancelButton];
[self presentViewController:alert animated:YES completion:nil];
} else{
dispatch_async(dispatch_get_main_queue(), ^{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];
notification.alertBody = content;
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;

[[UIApplication sharedApplication] scheduleLocalNotification:notification];
});
}
}

当应用程序处于事件状态时,UIAlertController 运行良好,但是当我终止该应用程序使其处于后台模式时,UILocalNotification 永远不会触发。但是我可以从 Xcode 中看到一些设备日志,证明远程通知已经被调用并运行代码行 :[[WalkieTalkie sharedWT].delegate onPushMessage:content]; 在 SDK 中。但是演示应用程序什么也没显示,没有任何反应。我是否将委托(delegate)代码放在了错误的位置?或者只是 SDK 处于事件状态而应用程序仍在后台?不懂,请指教,万分感谢!

最佳答案

您也可以在终止状态下调试应用。

如下图设置方案。

运行一次应用程序,它不会出现在设备上,当您点击图标时它只会运行。

所以当你运行应用程序时,实际上它会处于终止状态,所以现在触发 PushKit Payload 并将调试指针放在所需的位置。只需正确调试应用程序,您就可以找出问题所在。

enter image description here

关于ios - VoIP 推送不适用于 iOS SDK 演示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40560597/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com