2016-11-12 5 views
1

私はVoIP PushKitでiOS SDKを開発しています。iOS SDKデモでVoIPプッシュが動作しない

- (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がうまく機能:そして、ここでここではSDKのコードのプッシュ通知を受け取る

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

は、デリゲートが呼び出されますSDKデモMainViewController.mのコードですしかし、私がアプリを殺すとUILocalNotificationは決して起動しません。しかし、リモート通知が既に呼び出されたことを証明するXcodeのデバイスログが表示され、SDKの[[WalkieTalkie sharedWT].delegate onPushMessage:content];というコード行が実行されます。しかし、デモアプリは何も表示せず、反応もありません。デリゲートコードを間違った場所に置いたのですか?または、SDKだけがアクティブで、アプリはまだバックグラウンドにありますか?私は考えていない、私にいくつかのアドバイスをしてください、ありがとう!

+0

正常に機能しましたか? – Hasya

答えて

0

キル状態のアプリもデバッグできます。

以下のように設定します。

アプリを一度実行すると、デバイスには表示されません。アイコンをタップすると、それだけで動作します。

アプリを実行すると実際にはキル状態になるので、今度はPushKitペイロードを起動し、デバッグポインタを必要な場所に配置します。正しくアプリケーションをデバッグするだけで、問題を見つけ出すことができます。

enter image description here

私はこれまで、世界中どこででも関連助けることができるなら、私に教えてください。 幸いなコーディングがあります。

関連する問題