简体   繁体   English

VoIP 推送不适用于 iOS SDK 演示

[英]VoIP Push not work for an iOS SDK Demo

I'm developing an iOS SDK with VoIP PushKit.我正在使用 VoIP PushKit 开发 iOS SDK。 And here is the code in SDK when receive a push notification这是收到推送通知时 SDK 中的代码

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

Here is the code in SDK Demo MainViewController.m where delegate will be called :这是 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];
        });
    }
}

When app is active the UIAlertController works well, but when I kill the app makes it in background mode the UILocalNotification never fire.当应用程序处于活动状态时, UIAlertController 运行良好,但是当我杀死应用程序时,它会在后台模式下运行 UILocalNotification 永远不会触发。 However I can see some device log from Xcode that prove the remote notification had already been called and run the line of code : [[WalkieTalkie sharedWT].delegate onPushMessage:content];但是我可以从 Xcode 看到一些设备日志,证明远程通知已经被调用并运行代码行: [[WalkieTalkie sharedWT].delegate onPushMessage:content]; in SDK.在 SDK 中。 But the demo app just show nothing, none reaction.但是演示应用程序什么也没显示,没有反应。 Did I put the delegate codes in a wrong place?我是否将委托代码放在了错误的位置? Or just the SDK is active and app is still in background?或者只是 SDK 处于活动状态而应用程序仍在后台? I have no idea, please give me some advice, thanks a lot!我不知道,请给我一些建议,非常感谢!

You can debug app in kill state as well.您也可以在终止状态下调试应用程序。

Set scheme like below image.设置如下图所示的方案。

Run app once, it will not come on device, when you tap on icon then it will work only.运行一次应用程序,它不会出现在设备上,当您点击图标时,它只会工作。

So when you run app, actually it will be in kill state, so now fire PushKit Payload and put debug pointer at required place.所以当你运行应用程序时,实际上它会处于终止状态,所以现在启动 PushKit Payload 并将调试指针放在所需的位置。 just debug the app properly you would be able to figure out problem.只需正确调试应用程序,您就可以找出问题所在。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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