VoIP推送不适用于iOS SDK演示

3
我正在开发一个使用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中的代码,其中将调用委托:

- (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中。但演示应用程序什么也没有显示,没有任何反应。我是否将委托代码放错了地方?还是只有SDK处于活动状态,应用程序仍然在后台?我不知道,请给我一些建议,非常感谢!

它是否有效? - Hasya
1个回答

1
你可以在应用程序处于kill状态时进行调试。
设置如下图所示的方案。
运行应用程序一次,它不会出现在设备上,只有当你点击图标时才会起作用。
因此,当你运行应用程序时,实际上它处于kill状态,现在触发PushKit Payload并将调试指针放在需要的位置。只需正确地调试应用程序,就能找出问题。

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接