简体   繁体   English

iOS Flutter 没有收到推送通知

[英]iOS Flutter not getting push notifications

I'm having issues setting up push notifications for iOS on Flutter.我在 Flutter 上为 iOS 设置推送通知时遇到问题。 Another dev tried adding too - had the same problem.另一个开发人员也尝试添加 - 遇到了同样的问题。

TL;DR: Can anyone get pushes running on iOS Flutter with clean new build from stable channel? TL;DR:任何人都可以通过稳定渠道的全新构建在 iOS Flutter 上运行推送吗?

I followed setup steps described here: https://pub.dev/packages/firebase_messaging我遵循此处描述的设置步骤: https : //pub.dev/packages/firebase_messaging

Specifically:具体来说:

  • Generated app ID and push Key in https://developer.apple.com/account/resources/certificates/https://developer.apple.com/account/resources/certificates/ 中生成应用 ID 和推送密钥
  • Added info.plist to ios/Runner folder将 info.plist 添加到 ios/Runner 文件夹
  • Turned on Push capabilities开启推送功能
  • Uploaded APNS certificate to Firebase console将 APNS 证书上传到 Firebase 控制台
  • Made sure bundle ID is the same in App / Runner, info.plist and GoogleService-Info.plist确保 App / Runner、info.plist 和 GoogleService-Info.plist 中的 bundle ID 相同
  • Added lines in AppDelegate.swift在 AppDelegate.swift 中添加了几行

    if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as? if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate } UNUserNotificationCenterDelegate }

Pushes aren't coming.推不来。 Neither when app in background, not at all.当应用程序在后台时,根本不是。

I also tried another step - sending individual push.我还尝试了另一个步骤 - 发送个人推送。 Send code in CURL looks like this:在 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'

And the response is always this type: - First request is InvalidRegistration - Second and next same calls is NotRegistered并且响应始终是这种类型: - 第一个请求是 InvalidRegistration - 第二个和下一个相同的调用是 NotRegistered

Another person found similar problem this summer and posted on GitHub, but thread was closed: https://github.com/flutter/flutter/issues/30486另一个人今年夏天发现了类似的问题并在GitHub上发帖,但线程被关闭: https : //github.com/flutter/flutter/issues/30486

My Flutter doctor:我的颤振医生:

[✓] 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

ps Some things I've tried: ps我尝试过的一些事情:

  • Used another developer account (100% confirmed pushes are working on another project)使用另一个开发者帐户(100% 确认推送正在另一个项目上工作)
  • Used another Firebase account使用了另一个 Firebase 帐号
  • Recreated certificates, projects重新创建的证书、项目
  • Gave to try another developer to setup pushes his own (he also confirmed to be successfull in the past).尝试了另一个开发人员来设置他自己的推送(他过去也确认成功)。

Magically things just started working yesterday evening.神奇的是,昨天晚上事情才刚刚开始。 So first - just try now.所以首先 - 现在就试试。 If not working - recreate certificates and redo initialization steps.如果不起作用 - 重新创建证书并重做初始化步骤。 If still not working - pray and retry another day.如果仍然不工作 - 祈祷并改天重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM