2016-08-29 14 views
4

私はXCode 8 Beta、iOS 10 Versionでプッシュ通知を行っています。デバイス上でプッシュ通知を受信しました。通知をクリックすると、UNUserNotificationCenterDelegateの代理人が起動しましたが、アプリケーションが開かれましたが、userinfoに応答が表示されませんでした。サーバー側のiOS 10でプッシュを送信するためのパラメータを変更する必要がありますか。以下は私のコードです。 iOSの9でiOS:iOS 10で辞書情報が表示されないプッシュ通知

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]; 
    [application registerUserNotificationSettings:settings]; 

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; 
    center.delegate = self; 
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { 
     if (!error) { 
      NSLog(@"request authorization succeeded!"); 
     } 
    }]; 


- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { 

    NSLog(@"Notification is triggered"); 
    completionHandler(UNNotificationPresentationOptionAlert); 
} 

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler { 

    NSLog(@"Tapped in notification"); 
    NSLog(@"%@",response.notification); 
    NSString *actionIdentifier = response.actionIdentifier; 

    if ([actionIdentifier isEqualToString:@"com.apple.UNNotificationDefaultActionIdentifier"] || 
     [actionIdentifier isEqualToString:@"com.apple.UNNotificationDismissActionIdentifier"]) { 
     return; 
    } 
} 

aps =  { 
    alert = "Multi extra param push."; 
    badge = 0; 
    sound = default; 
}; 
t = I; 
url = "http://www.google.com"; 

とiOSの10

alert = "Multi extra param push."; 
badge = 0; 
sound = default; 
+1

なぜiOS版ベータ版を使用していますか? – Rushabh

+0

このNSLogを試してください(@ "%@"、[response.notification.request.content.userInfo objectForKey:@ "aps"]); –

+0

iOS 9 aps = { alert = "複数の追加パラメータプッシュ"; バッジ= 0; sound =デフォルト; }; t = I; url = "http://www.google.com"; iOS 10ではalert = "複数の追加パラメータプッシュ"; バッジ= 0; sound =デフォルト; – Kashif

答えて

13
- (void)userNotificationCenter:(UNUserNotificationCenter *)center 
     willPresentNotification:(UNNotification *)notification 
     withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { 
    NSLog(@"%@", notification.request.content.userInfo); 
} 

- (void)userNotificationCenter:(UNUserNotificationCenter *)center 
didReceiveNotificationResponse:(UNNotificationResponse *)response 
     withCompletionHandler:(void(^)())completionHandler { 
    NSLog(@"%@", response.notification.request.content.userInfo); 
} 
0
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{    
    NSLog(@"%@",userInfo);   
} 

でそれを確認してください。

+4

ユーザーがタップして通知してアプリに来ると、これはiOS 10で動作しません。 – Kashif

+0

iOSで使用できる@導入済み:3.0、廃止予定:10.0 –

関連する問題