Flutter、Objective-C、および MoEngage-iOS-SDK(バージョン 7.x.x、8.x.x、9.x.x)を使用してiOSデバイスで一般的なプッシュ通知の問題を回避する方法

問題

iOSデバイスでFlutter、Objective-C、MoEngage-iOS-SDK(バージョン7.x.x、8.x.x、9.x.x)を使用している場合、プッシュ通知に関する一般的な問題には、配信失敗、画面ナビゲーション、ディープリンク、リッチランディングが含まれます。

ソリューション

次の手順を実行します。

  1. Firebaseプロキシ :
    • Firebaseプッシュ通知を使用していない場合は、info.plistにFirebaseAppDelegateProxyEnabledキーを追加し、Boolean値をFalse/NOに設定してFirebaseプロキシを無効にします。
    • プッシュ通知をテストします。成功した場合、これ以上のアクションは必要ありません。そうでない場合は、以下の手順に従ってください。
    • Firebaseプッシュ通知を使用している場合、このステップをスキップし、以下の手順に進んでください。
  2. MoEngageプロキシを無効にする :
    • info.plistにMoEngageAppDelegateProxyEnabledキーを追加し、値をBoolean = false/NOに設定します boolean.png
  3. didRegisterForRemoteNotificationsWithDeviceToken 関数をオーバーライドする :
    • AppDelegate.m ファイルの didRegisterForRemoteNotificationsWithDeviceToken 関数をオーバーライドします。
      Objective-C
      - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
      { 
        [super application: application didRegisterForRemoteNotificationsWithDeviceToken: deviceToken]; 
        
        //7.xx version
        [[MoEngage sharedInstance] setPushToken:deviceToken];
        
        //8.xx version
        [[MOMessaging sharedInstance] setPushToken:deviceToken];
        
        //9.xx version
        [[MoEngageSDKMessaging sharedInstance] setPushToken:deviceToken];
      }
  4. UNUserNotificationCenterDelegate 関数のオーバーライド :
    • AppDelegate.m ファイルで UNUserNotificationCenterDelegate 関数をオーバーライドします。
      Objective-C
      //Try without willPresent if it works good to go! else override it
      - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
        if (notification.request.content.userInfo != nil) {
          NSDictionary *dictionary = notification.request.content.userInfo;
          if (dictionary[@"moengage"] != nil) {
            completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
          } else {
            [super userNotificationCenter: center willPresentNotification: notification withCompletionHandler:completionHandler];
          }
      }
      
      - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
      {
        [super userNotificationCenter: center didReceiveNotificationResponse: response withCompletionHandler: completionHandler];
        
        //7.xx version
        [[MoEngage sharedInstance] userNotificationCenter:center didReceiveNotificationResponse:response];
      
        //8.xx version
        [[MOMessaging sharedInstance] userNotificationCenter:center didReceive:response];
        
        //9.xx version
        [[MoEngageSDKMessaging sharedInstance] userNotificationCenter:center didReceive:response];
        
        completionHandler();
      }

この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています

How can we improve this article?