Workmanager等のバックグラウンド処理を入れたら、FCMが使えなくなった時の対処法
2593 ワード
環境
- Mac OS Catalina
- Flutter
- Firebase
やりたいこと
下記のような形でFCMと同時に他のバックグラウンド処理をやりたい
-
FCM( remote notification )
- Foreground
- Background
- Killed
-
- Foreground
- Background
-
- Background
- Killed
問題
Workmanager等のバックグラウンド処理を実装完了して喜んでたら、iOSで(Android はwork)、FCMを使った通知が来なくなっていた…
解決策
Firebase Cloud messaging でのメソッド実装入れ替え を設定する必要があったみたい
変更するファイルは、 info.plist
と AppDelegate.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
Author And Source
この問題について(Workmanager等のバックグラウンド処理を入れたら、FCMが使えなくなった時の対処法), 我々は、より多くの情報をここで見つけました https://qiita.com/wakki_haya/items/eb49561f4cb9260a3fce著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .