[英]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 處於活動狀態而應用程序仍在后台? 我不知道,請給我一些建議,非常感謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.