プッシュ通知に関してFlutterとIOSに問題があります。
私のセットアップと機能するもの:
1)私firebase_messaging: ^5.1.6
はエラーなしでパッケージをインストールしました/ IOSのすべての指示に従いました
2)IOSのユーザー権限を要求し、プッシュ通知の受信を受け入れました
3)IOSおよびAndroidデバイスでFCMトークンを取得できます
4)Apple開発者セクションでキーを作成し、FCMにキーを追加しました
5)テスト時にアプリを閉じた/バックグラウンドに送信した-まだ運がない
6)Xcodeを使用してgoogle-service-infoファイルをRunnerに追加しました
7)XCode機能にプッシュ通知とバックグラウンド通知を追加しました
8)iPhone 7の物理デバイスと物理的なiPadでテストしています
curlを使用してIOSデバイスに通知を送信しました
curl -X POST --header "Authorization: key=<myAuthKEY>" \
--Header "Content-Type: application/json" \
https://fcm.googleapis.com/fcm/send \
-d "{\"to\":\"<myDeviceKey>\",\"notification\":{\"body\":\"Hello\"},\"priority\":10}"
firebaseから成功の応答を受け取ります
{"multicast_id":<SomeIdHere>,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"<SomeIdHere>"}]}
トークンを取得する方法は次のとおりです。
firebaseMessaging.getToken().then((String token) {
_authModel.setNotificationToken(token);
});
IOSでアプリを実行しても、Firebaseエラーは発生しません。
私はこれを2日間いじっていますので、少し面倒になっています。上記のすべてがAndroidで動作するようです。
どんな提案でもしてください。
Flutter Doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.15 19A583, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.38.1)
[✓] Connected device (4 available)
• No issues found!
私のAppDelegate.mファイル
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@import Firebase;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end