Flutterfire: [firebase_messaging] in iOS, onMessage handler is only called when running via Xcode. Does not fire when run via flutter run

Created on 11 Mar 2020  Â·  1Comment  Â·  Source: FirebaseExtended/flutterfire

Describe the bug
The onMessage handler does not fire unless run via Xcode.

To Reproduce
Steps to reproduce the behavior:

  1. Follow the setup instructions at https://pub.dev/packages/firebase_messaging#-readme-tab- exactly as it says to do.
  2. Do not add this snippet (contrary to what instructions say) or else it won't work at all. This is another bug (more here: #1041) :
if #available(iOS 10.0, *) {
  UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
  1. Launch app on a physical iOS device via Xcode and send a notification from Firebase while app is foregrounded. It will run the onMessage handler and show your print statement.
  2. Now launch the same app via flutter run and you won't be able to see the print statement because onMessage is never called.

Expected behavior
onMessage should always be called.

Additional context
firebase_messaging: ^6.0.12

Flutter 1.14.6 • channel beta • https://github.com/flutter/flutter.git
Framework • revision fabeb2a16f (6 weeks ago) • 2020-01-28 07:56:51 -0800
Engine • revision c4229bfbba
Tools • Dart 2.8.0 (build 2.8.0-dev.5.0 fc3af737c7)
bug

Most helpful comment

I found this to be due to a project cleaning issue. After doing flutter clean, xcodebuild clean, deleting derived data, deleting pods, and starting again this no longer happens.

>All comments

I found this to be due to a project cleaning issue. After doing flutter clean, xcodebuild clean, deleting derived data, deleting pods, and starting again this no longer happens.

Was this page helpful?
0 / 5 - 0 ratings