Flutter Push 通知未显示在 IOS 上
我在使用 Flutter 和 IOS 时遇到了推送通知方面的问题.
I am having an issue with Flutter and IOS in regards to Push notifications.
我的设置和有效的东西:
My setup and things that work:
1) 我安装了 firebase_messaging: ^5.1.6
包,没有错误/按照他们对 IOS 的所有说明进行操作
1) I installed the firebase_messaging: ^5.1.6
package with no errors / followed all their instructions for IOS
2) 我已在 IOS 上征得用户许可并接受接收推送通知
2) I have asked user permission on IOS and accepted to receive push notifications
3) 我能够在 IOS & 上获得 FCM 令牌安卓设备
3) I am able to get an FCM token on IOS & Android devices
4) 我在 Apple 开发者部分创建了一个 Key 并将该 Key 添加到 FCM
4) I have created a Key in the Apple developer section and added the key to FCM
5) 我在测试时关闭了应用程序/将其发送到后台 - 仍然没有运气
5) I have closed the app / sent it to the background when testing - still no luck
6) 我已使用 Xcode 将 google-service-info 文件添加到 Runner
6) I have added the google-service-info file to Runner using Xcode
7) 我在 XCode 功能中添加了推送通知和后台通知
7) I have added push notifications and background notifications in XCode Capabilities
8) 我正在 iPhone 7 物理设备和物理 iPad 上进行测试
8) I am testing on an iPhone 7 physical device, and a physical iPad
我使用 curl 向 IOS 设备发送通知
I have used curl to send a notification to an IOS device
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 的成功响应
I get a success response from firebase
{"multicast_id":<SomeIdHere>,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"<SomeIdHere>"}]}
这是我检索令牌的方法:
Here is how I retrieve the token:
firebaseMessaging.getToken().then((String token) {
_authModel.setNotificationToken(token);
});
当我在 IOS 上运行应用程序时,我没有收到任何 Firebase 错误.
When I run the app on IOS, I do not get any Firebase errors.
我已经折腾了 2 天了,所以有点烦人,以上所有似乎都适用于 Android.
I've been messing around with this for 2 days now, so it's getting a bit annoying, all the above seems to work on Android.
任何建议,请.
颤振医生:
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 文件
My AppDelegate.m file
#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
这不是很漂亮,您可能需要提供更多详细信息,但请将此问题提交到 https://github.com/FirebaseExtended/flutterfire/issues.否则,快速搜索 iOS 推送通知 问题显示了各种报告.这里有一些类似的,也许一个和你的有关?
It's not pretty, you may need to provide a lot more details, but please file this issue to https://github.com/FirebaseExtended/flutterfire/issues. Otherwise, a quick search of iOS push notification issues shows variety of reports. Here are some similar ones, maybe one is related yours?
-
https://github.com/FirebaseExtended/flutterfire/issues/1799
- 仅在前台显示,RE:
5) 我在测试时关闭了应用程序/将其发送到后台 - 仍然没有运气
- 与背景问题相关
- 您是否从控制台尝试过?,回复:Stefano Saitta 的评论
- 适用于 Android,但不适用于 iOS
- 其他插件可以破坏它吗?
或者,如果您已经提交了一份,请分享链接!其他人可能会向您添加反馈.
Or if you already filed one, share the link! Others may add feedback to yours.
- 仅在前台显示,RE: