簡體   English   中英

VoIP 推送不適用於 iOS SDK 演示

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

我正在使用 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 處於活動狀態而應用程序仍在后台? 我不知道,請給我一些建議,非常感謝!

您也可以在終止狀態下調試應用程序。

設置如下圖所示的方案。

運行一次應用程序,它不會出現在設備上,當您點擊圖標時,它只會工作。

所以當你運行應用程序時,實際上它會處於終止狀態,所以現在啟動 PushKit Payload 並將調試指針放在所需的位置。 只需正確調試應用程序,您就可以找出問題所在。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM