我在 Flutter 上为 iOS 设置推送通知时遇到问题。
另一个开发人员也尝试添加 - 有同样的问题。
TL;DR:任何人都可以在 iOS Flutter 上使用来自稳定 channel 的全新构建推送吗?
我按照此处描述的设置步骤进行操作:
https://pub.dev/packages/firebase_messaging
具体来说:
如果 #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
推不来。当应用程序在后台时,根本没有。
我还尝试了另一个步骤 - 发送个人推送。在 CURL 中发送代码如下所示:
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Authorization:key=AIza_legacy_key" \
-d \
'{
"to": "my_push_token",
"notification":
{"body": "test_body",
"title": "test_title"
},
"priority": "high",
}
' \
'https://fcm.googleapis.com/fcm/send'
响应总是这种类型:
- 第一个请求是 InvalidRegistration
- 第二次和下一次相同的调用未注册
另一个人在今年夏天发现了类似的问题,并在 GitHub 上发帖,但是线程被关闭了:
https://github.com/flutter/flutter/issues/30486
我的 flutter 医生:
[✓] Flutter (Channel unknown, v1.12.13+hotfix.7, on Mac OS X 10.15.3 19D76, locale ru-UA)
• Flutter version 1.12.13+hotfix.7 at /Users/reiven/flutter
• Framework revision 9f5ff2306b (2 weeks ago), 2020-01-26 22:38:26 -0800
• Engine revision a67792536c
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/reiven/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio 3.6 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.7.5
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio 3.6 Preview.app/Contents
• Flutter plugin version 43.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (4 available)
• iPhone • 96c120610d684dbab7f5e4d036a7f48041755f96 • ios • iOS 12.3.1
• iPhone 11 Pro Max • 8ABC99D3-6C46-4A3D-968B-F5719AA92C97 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• Chrome • chrome • web-javascript • Google Chrome 79.0.3945.130
• Web Server • web-server • web-javascript • Flutter Tools
p.s.我尝试过的一些事情:
最佳答案
神奇的是,事情昨天晚上才开始起作用。
所以首先 - 现在尝试。如果不工作 - 重新创建证书并重做初始化步骤。如果仍然无法正常工作 - 祈祷并改天重试。
关于iOS Flutter 没有收到推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60151597/