1

私のアプリは、新しいiOS 10リッチプッシュのNotificationService拡張機能を実装しています。iOS 10より前のUNNotificationServiceExtensionでアプリを実行するにはどうすればよいですか?

iOS 10ではすべてが正常に動作しますが、iOS 10以前のデバイスもサポートしたいと思います。もちろん、リッチプッシュではなく、通常のプッシュだけです。 Xcodeの展開ターゲットを例えば以下のように下げます。 8.0または9.0と、私は次のエラーを取得し、古いシミュレータやデバイス上で実行しようとしている:

Simulator: The operation couldn’t be completed. (LaunchServicesError error 0.) 
Device: This app contains an app extension that specifies an extension point identifier that is not supported on this version of iOS for the value of the NSExtensionPointIdentifier key in its Info.plist. 
私はあなたが追加すると、あなたのアプリが唯一10+ iOSの上で実行されることを示すAppleが正式に何かを見つけることができませんでした

サービス拡張 - 誰かがそれを確認できますか?

+0

ios10デバイスのUIUserNotificationsを実装する必要があります。 –

+0

@ bhavuk-jainどうすればいいですか?詳細やリンクがありますか? –

答えて

3

Bhavukジャイナ教は、古いiOSの通知をサポートするが、LaunchServicesErrorを解決していないかについて話しています。これを解決するには、展開情報で拡張ターゲット - >一般 - >展開ターゲットの設定(このケースでは10.0)に移動する必要があります。

2

まず通知サービスを初期化します。

func initializeNotificationServices() -> Void { 


     if #available(iOS 10.0, *) { 


      let center = UNUserNotificationCenter.current() 
      center.delegate = self 
      center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in 

       if granted { 
        UIApplication.shared.registerForRemoteNotifications() 
       } 

      } 
     }else { 

      let settings = UIUserNotificationSettings(types: [.sound, .alert, .badge], categories: nil) 
      UIApplication.shared.registerUserNotificationSettings(settings) 
     } 

    } 

成功したリモート通知のために登録されている場合、これはすべてのデバイスため呼び出されます:、iOSの10のみの場合

optional public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) 

リモート通知を処理する:

iOSの10以下のデバイスの場合
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) { 

     let userInfo = response.notification.request.content.userInfo 

     notificationReceived(userInfo: userInfo, application: nil) 
    } 

    @available(iOS 10.0, *) 
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { 

     let userInfo = notification.request.content.userInfo 

    } 

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { 

    } 
-1

フレームワークのステータスをオプションに変更します。必要な場合は、いくつかのフレームワークがIOS 9で動作しません。 enter image description here

関連する問題