Flutterfire: [firebase_messaging] No Message in iOS Release Mode

Created on 31 May 2020  Â·  14Comments  Â·  Source: FirebaseExtended/flutterfire

Describe the bug
Android Debug: Work
Android Release: Work
iOS Debug: Work
iOS Release: Not Work

To Reproduce


Steps to reproduce the behavior:

  1. Clone sample app: https://github.com/tuanha2000vn/fcm_ios_release_bug
  2. Build iOS App and click the button 'https://fcm.googleapis.com/fcm/send'
  3. Notice the difference of iOS app in Debug Mode vs Release Mode result

Expected behavior
Send data:

{
 "to" : "d944GNsO90n6mOdYPd21hl:APA91bF7SONl9E7E4sFhtTdKeH_Zmesh_n1KJAWE_y7Kod8z9RSa8hHFMKELv0WHGUAGdxdiZVwNYPyPTxSxODIE-e8wyqKs2C-lhQ6JPocxJmZueMiTfRj-HcD-QvqRXpGIefj4K-Nw",
 "collapse_key" : "type_a",
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification"
 },
 "data" : {
     "body" : "Body of Your Notification in Data",
     "title": "Title of Your Notification in Title",
     "key_1" : "Value for key_1",
     "key_2" : "Value for key_2"
 }
}

iOS Debug:

{
    "multicast_id": 2894437391698496198,
    "success": 1,
    "failure": 0,
    "canonical_ids": 0,
    "results": [
        {
            "message_id": "1590877840476643"
        }
    ]
}

iOS Release:

{
    "multicast_id": 1281464412959576484,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidRegistration"
        }
    ]
}

Additional context
pubspec.yaml

name: hassdash
description: A new Flutter application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  firebase_analytics: any
  firebase_messaging: 6.0.16
  firebase_core: ^0.4.0

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.
  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

Flutter doctor
Run flutter doctor and paste the output below:

[✓] Flutter (Channel v1.12.13-hotfixes, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287, locale en-VN)
    • Flutter version 1.12.13+hotfix.9 at /Users/hoanganhtuan/development/flutter
    • Framework revision f139b11009 (9 weeks ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/hoanganhtuan/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-R, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.1

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2

[✓] Connected device (4 available)
    • Nokia 7 plus              • B2NGAA8830704049                         • android-arm64 • Android 10 (API 29)
    • Android SDK built for x86 • emulator-5554                            • android-x86   • Android 10 (API 29) (emulator)
    • TuanHA’s iPhone X         • c938992824b3503c5d9daff372c9bb4644d4b330 • ios           • iOS 13.4.1
    • iPhone 11                 • 91E970E4-89D5-41D9-9FEC-C281D4FD6B66     • ios           • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
ios messaging bug

Most helpful comment

Ok, I think I've fixed it.

These are the change make iOS release mode work again:

  1. Info.plist
    <key>FirebaseAppDelegateProxyEnabled</key>
    <false/>

Change to

    <key>FirebaseAppDelegateProxyEnabled</key>
    <string>NO</string>
  1. pubspec.yaml
firebase_messaging: ^6.0.16

Change to

firebase_messaging: 6.0.15

These change are against official document but I don't know why it work but hey it work!

All 14 comments

Ok, I think I've fixed it.

These are the change make iOS release mode work again:

  1. Info.plist
    <key>FirebaseAppDelegateProxyEnabled</key>
    <false/>

Change to

    <key>FirebaseAppDelegateProxyEnabled</key>
    <string>NO</string>
  1. pubspec.yaml
firebase_messaging: ^6.0.16

Change to

firebase_messaging: 6.0.15

These change are against official document but I don't know why it work but hey it work!

I am having the same problem but the suggestion didn't help. I also followed below:
https://github.com/FirebaseExtended/flutterfire/issues/1041
didn't solve my issue too..

I am having the same problem but the suggestion didn't help. I also followed below:

1041

didn't solve my issue too..

https://www.youtube.com/watch?v=9zWs0I7UpcQ ?
it works for my

This is real! Push notification works fine in debug mode but doesn't work if the app is in release mode. I get the same InvalidRegistration error when I send notification on token received in release mode. However, it works just fine for the token received in debug mode. I am using firebase_messaging: ^7.0.0

Try to add application.registerForRemoteNotifications() in your AppDelegate.swift. It worked for me. ver 7.0.0

Try to add application.registerForRemoteNotifications() in your AppDelegate.swift. It worked for me. ver 7.0.0

It doesn't work for me. ver 7.0.3

This definitely worked for me.

 <key>FirebaseAppDelegateProxyEnabled</key>
 <string>0</string>

This definitely worked for me.

 <key>FirebaseAppDelegateProxyEnabled</key>
 <string>0</string>

it doesn't work for me ver 7.0.3, in ios 13.7. onMessage did not call with release mode. Have any other solution?

I have fixed that by using APNs key. maybe I have a mistake in config production APNs Certificates.

This worked for me when running on iOS14 and Xcode 12.1 on release/profile mode. Prior, it was only working in debug mode on my device. As mentioned in previous comments, I did the following....
1. Switched my firebase_messaging package from 7.0.3 to 7.0.0
2. I then changed this in my Info.plist -
<key>FirebaseAppDelegateProxyEnabled</key> <false/> to <key>FirebaseAppDelegateProxyEnabled</key> <string>0</string>

Hopefully this helps!

I tried this @Andrew-Tolentino. Didn't work.
If I donot change my info.plist I get the notification when the app is closed but not when it's open. I check it by adding a toast in onMessage and onResume.
If I add this in my info.plist I donot get notifications at all.

But everything works fine on emulator or on physical device in debug mode. when I create a build for development and distribution it doesn't work.

This worked for me when running on iOS14 and Xcode 12.1 on release/profile mode. Prior, it was only working in debug mode on my device. As mentioned in previous comments, I did the following....

  1. Switched my firebase_messaging package from 7.0.3 to 7.0.0
  2. I then changed this in my Info.plist -
    <key>FirebaseAppDelegateProxyEnabled</key> <false/> to <key>FirebaseAppDelegateProxyEnabled</key> <string>0</string>

Hopefully this helps!

Lifesaver, spent last 4 hours trying to find the issue. This worked for me.

@varundroid Hi. Were you able to receive notification on ios while the app is running ?
I tried adding a toast message in onMessage method to see if the app receives notifications while in foreground. I see the toast message when I run the app on simulator but if I create a build and run on my physical device it doesn't show.

I have already tried the above mentioned fix.

This worked for me when running on iOS14 and Xcode 12.1 on release/profile mode. Prior, it was only working in debug mode on my device. As mentioned in previous comments, I did the following....

  1. Switched my firebase_messaging package from 7.0.3 to 7.0.0
  2. I then changed this in my Info.plist -
    <key>FirebaseAppDelegateProxyEnabled</key> <false/> to <key>FirebaseAppDelegateProxyEnabled</key> <string>0</string>

Hopefully this helps!

On ios 14.2 | i switch my firebase_messaging 7.0.3 to 7.0.0
debug mode is work but on release mode don't work :(

Was this page helpful?
0 / 5 - 0 ratings