【发布时间】:2020-06-06 13:55:59
【问题描述】:
我已经配置了带有颤振的 Firebase 云消息传递通知正在前台工作。但在后台运行或应用程序被杀死时无法正常工作。
以下步骤已完成。
- 生成的应用程序 ID 并按下键 https://developer.apple.com/account/resources/certificates/
- 将 info.plist 添加到 ios/Runner 文件夹
- 开启推送功能
- 已将 APNS 证书上传到 Firebase 控制台
- 在 AppDelegate.swift 中添加了行
还尝试按照Flutter Firebase Cloud Messaging - Notification when app in background 的建议删除以下行,但仍然无法正常工作。
if (@available(iOS 10.0, *)) { [UNUserNotificationCenter currentNotificationCenter].delegate = (id) self; }
Flutter Doctor
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.14.5 18F132, locale en-IN)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] Connected device (3 available)
我注意到一件事,当第一次安装应用程序时,它并没有要求我检查我是否允许应用程序发送推送通知。
我的代码在登录页面后的页面上有以下几行。
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, badge: true, alert: true));
_firebaseMessaging.onIosSettingsRegistered
.listen((IosNotificationSettings settings) {
print("Settings registered: $settings");
});
还交叉检查是否勾选了所有以下设置。
【问题讨论】:
-
新版本发布对此有何更新?
-
我猜你正在使用 local_notification 这个包,这是 local_notification 和这个包之间的常见问题冲突
-
我花了一个星期,但没有任何效果。
标签: ios firebase flutter firebase-cloud-messaging