LoginSignup
0
0

More than 3 years have passed since last update.

Workmanager等のバックグラウンド処理を入れたら、FCMが使えなくなった時の対処法

Posted at

環境

  • Mac OS Catalina
  • Flutter
  • Firebase

やりたいこと

下記のような形でFCMと同時に他のバックグラウンド処理をやりたい

問題

Workmanager等のバックグラウンド処理を実装完了して喜んでたら、iOSで(Android はwork)、FCMを使った通知が来なくなっていた…

解決策

Firebase Cloud messaging でのメソッド実装入れ替え を設定する必要があったみたい
image.png

変更するファイルは、 info.plistAppDelegate.m の2つ

info.plist
    ...
    <key>FirebaseAppDelegateProxyEnabled</key>
    <false/> 
   ...
AppDelegate.m
@import Firebase;

void registerPlugins(NSObject<FlutterPluginRegistry>* registry) {
  [GeneratedPluginRegistrant registerWithRegistry:registry];
}

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //Other plugins
   [GeneratedPluginRegistrant registerWithRegistry:self];
   return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

// このメソッドを追加
- (void)application:(UIApplication *)application
    didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [FIRMessaging messaging].APNSToken = deviceToken;
    [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}


@end

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0