iOS Flutter 没有收到推送通知

标签 ios flutter push-notification

我在 Flutter 上为 iOS 设置推送通知时遇到问题。
另一个开发人员也尝试添加 - 有同样的问题。

TL;DR:任何人都可以在 iOS Flutter 上使用来自稳定 channel 的全新构建推送吗?

我按照此处描述的设置步骤进行操作:
https://pub.dev/packages/firebase_messaging

具体来说:

  • 生成应用 ID 并在 https://developer.apple.com/account/resources/certificates/ 中推送 Key
  • 将 info.plist 添加到 ios/Runner 文件夹
  • 开启推送功能
  • 已将 APNS 证书上传到 Firebase 控制台
  • 确保 App/Runner、info.plist 和 GoogleService-Info.plist 中的 bundle ID 相同
  • 在 AppDelegate.swift 中添加了行

    如果 #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.我尝试过的一些事情:
  • 使用了另一个开发者帐户(100% 确认推送正在另一个项目中工作)
  • 使用了另一个 Firebase 帐户
  • 重新创建证书、项目
  • 给了尝试另一个开发者来设置他自己的推送(他过去也证实是成功的)。
  • 最佳答案

    神奇的是,事情昨天晚上才开始起作用。
    所以首先 - 现在尝试。如果不工作 - 重新创建证书并重做初始化步骤。如果仍然无法正常工作 - 祈祷并改天重试。

    关于iOS Flutter 没有收到推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60151597/

    相关文章:

    ios - 如何获取主包中子文件夹的路径?

    ios - MPNowPlayingInfoCenter Remote 在 iOS 10 中响应不正确

    ios - 如何最好地处理 iOS 应用程序中没有互联网连接的问题

    dart - Flutter - DragBox 反馈动画到原始位置

    ios - 如果负载中缺少锁定 key ,推送通知是否会显示

    ruby-on-rails-4 - 自动化域添加和验证步骤以使用 Google 日历的推送通知

    ios - iphone ios 上的 swift 3 中的弹出窗口

    animation - 如何为可扩展的 Flutter 小部件设置动画以将其滑出屏幕

    ios - Pushwoosh 上的 .p12 文件无效

    flutter - 结合冷冻和 hive