2016-12-05 17 views
0

私はAPNSを使用して、それは私がプッシュ通知を登録カントiOS10に新しいプッシュAPIの変更ので、私は次の変更を挿入してiOSの9 に作業罰金です:iOSのプッシュ通知

  1. は、プッシュ通知を有効にしますターゲット機能タブをクリックします。我々はOSのバージョンを確認し、以下のように登録didFinishLaunchingWithOptionsで
  2. 私はiOSの9とiOS 10に登録を実行するために管理が、私は問題がいくつかあり、この変更により
    if (SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")) { 
    
        //ios 10 Notifiction 
        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; 
        center.delegate = self; 
        [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ 
         if(!error){ 
          [[UIApplication sharedApplication] registerForRemoteNotifications]; 
          NSLog(@"iOS 10 push notification register successfully "); 
         } 
        }]; 
    } else { 
        // iOS 8-9 Notifications 
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 
    
        [[UIApplication sharedApplication] registerForRemoteNotifications]; 
        NSLog(@"iOS 9 push notification register successfully "); 
    
    } 
    

  1. ターゲット機能タブでプッシュ通知を有効にすると、登録が正常に完了したにもかかわらず、プッシュ通知がiOS 9で機能しなくなります。
  2. 登録は正常に完了しましたが、iOS 10ではプッシュは機能しません。

私はiOSの9上で動作するように(同じコードで)ターゲット機能のタブにプッシュリターンをプッシュ通知をオフにしますがあれば、私は

+0

これを一度ご覧ください。http://stackoverflow.com/questions/39267549/ios-how-to-integrate-push-notification-in-ios-10/39268135#39268135 –

+0

すでにこれも試してください。機能タブでプッシュ通知を有効にし、UserNotificationsフレームワークとUNUserNotificationCenterDelegateを追加し、両方のOSバージョンでOSバージョンと登録が正常に完了したことを確認します。問題はdidReceiveRemoteNotificationが呼び出していないことです。私は通知のユーザーアクションについて知る必要はありませんが、didReceiveRemoteNotification:userInfo fetchCompletionHandlerも実装しました –

答えて

0
iOSの10にAPNSに登録傾けることに注意してください。
if #available(iOS 8.0, *) { 
     let settings: UIUserNotificationSettings = UIUserNotificationSettings (types: [.alert, .badge, .sound], categories: nil) 
     application.registerUserNotificationSettings(settings) 
     application.registerForRemoteNotifications() 
    }else { 
     let types: UIRemoteNotificationType = [.alert, .badge, .sound] 
     application.registerForRemoteNotifications(matching: types) 
    } 
+0

ありがとうございます。問題は登録ではなく、プッシュを受信して​​います –