On Flutter's dev channel (and all other channels), Firebase Messaging's onResume and onMessage callbacks are broken on iOS as of 1.7.4. We have done extensive testing, and it works fine with v1.6.3, and even v1.6.7. onLaunch works fine, and all callbacks work fine on Android. The callbacks are not called at all, and the following error can be found in the iOS logs:
SpringBoard(UserNotificationsServer)[52] <Notice>: [com.ourapp.someapp] Application foreground
launch action for notification response action com.apple.UNNotificationDefaultActionIdentifier
recieved action response <BSActionResponse: 0x2839cde00; error:
<NSError: 0x2834c37e0; domain: BSActionErrorDomain; code: 4> {
description = "The operation couldn\M-b\M^@\M^Yt be completed. (BSActionErrorDomain error 4.)";
}>
Every now and then it shows error 1 instead of error 4. This error is terribly documented online (not at all), but I recognise it from when we had our iOS app configurated wrong for push notifications. Our configuration is fine now. We build via a build server, so we still have all the logs. We built a version on June 20st (from now on referred to as A), and a version on June 21st (B). A was v1.6.3, B was v1.7.4. We've since tested v1.6.7, and that version is fine too. Version A calls the callbacks and works fine. Version B does not. The issue is not related to our code since on our current HEAD, the callbacks still only work < v1.7.4.
Now, we have had to revert back to Flutter v1.6.7, meaning we no longer have access to app bundles and TransferableTypedData, which is, of course, a major blocker for our work.
Flutter version for A:
Flutter 1.6.3 • channel beta • https://github.com/flutter/flutter.git
Framework • revision bc7bc94083 (4 weeks ago) • 2019-05-23 10:29:07 -0700
Engine • revision 8dc3a4cde2
Tools • Dart 2.3.2 (build 2.3.2-dev.0.0 e3edfd36b2)
Flutter version for B:
Flutter 1.7.4 • channel dev • https://github.com/flutter/flutter.git
Framework • revision dfecafa4ab (7 days ago) • 2019-06-14 09:46:23 -0700
Engine • revision 2589785b5c
Tools • Dart 2.4.0
Firebase messaging version: 5.1.0, but applies to every version since at least 5.0.1 (that's as far as we went)
@JaspervanRiet
The issue at https://github.com/flutter/flutter/issues/36201 has been closed and moved here. Future collaboration on this issue will be done here.
One note from my side on this issue:
Thought i had the same problem, because i also did not get any onMessage() and onResume() callbacks.
But it was the local notification plugin which i also had integrated.
Even though i did not initialize it i needed to remove it completely from pubspec.yaml.
After that notifications continued working on iOS.
Runnning:
[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.14.6 18G95, locale en-DE)
• Flutter version 1.9.1+hotfix.2 at ...
• Framework revision 2d2a1ffec9 (6 weeks ago), 2019-09-06 18:39:49 -0700
• Engine revision b863200c37
• Dart version 2.5.0
We've solved the issue for us. Our project is rather old for a Flutter project at this point; we've been at work on it since July 2018. I gave up trying to solve the issues on the iOS side and created a new project, using Swift (unlike our actual project, which used Objective-C still). I then set the same configuration we have in our actual project (and of course copied over all Dart code), and now notifications work, on all versions.
I'm not sure the issue should be closed since we essentially just sidestepped it.
Also having this issue.
Works flawlessly on android, but on iOS it never gets called. Running on 1.9.1+hotfix.4
I believe this:
https://github.com/FirebaseExtended/flutterfire/pull/121#
May be related and be the solution to the issue we're having.
Hi guys, Any solutions to this yet ?
This issue does seem to be related to #121 which should resolve it.
~Tried implementing #121 to my app instead of the live branch and did not seem to fix the issue.~
~My app is using swift, though, and the code I used in AppDelegate.swift may have not been correct.~
EDIT: #121 does fix the issue. I had an error elsewhere causing my code in onMessage not to execute. Hopefully it fixes the rest of your issues too!
Ahh I just found out this issue until now I thought I've been doing wrong as it works intended on Android.
Closing now that #121 is merged.
@kroikie Is there any additional steps that should be performed to fix this (besides ones from package page)?
I'm still having this issue - data message are consumed as expected, but notification messages are ignored by onMessage (or any other callback) if app is in foreground. They are displayed normally in notification tray if app is in background, but callbacks are not fired if tapped.
I'm using firebase_messaging 6.0.1 and flutter 1.12.13+hotfix.1 from beta channel. (Although I've tried plugin version straight from github with same result)
@kroikie I thought this issue is fixed with adding below but I don't get any callbacks after update to 1.12.13+hotfix.6. This should be reopened.
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
@kroikie I thought this issue is fixed with adding below but I don't get any callbacks after update to 1.12.13+hotfix.6. This should be reopened.
if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate }
I am also on 1.12.13+hotfix.6 and facing the same issue. None of the callbacks are working on actual device in foreground iOS 13.3.
I have the same issue as @njovy and @WahibAbdul.
I am on 1.12.13+hotfix.5 and the device has iOS 12.4.3 installed. The callbacks are not fired. Works on Android.
I have the same issue as @njovy and @WahibAbdul.
I am on 1.12.13+hotfix.5 and the device has iOS 13.3 installed. The callbacks are not fired.
Same behaviour here with Flutter 1.12.13+hotfix.5 and iOS 13.3. - onResume and onMessage don't fire. Please reopen @kroikie @BondarenkoStas 🙏
Same behavior here. on
ios 13.1.3
flutter 1.12.13+hotfix.5
I have the same problem with:
iOS 13.3
Flutter v1.13.6 (dev channel)
@kroikie I thought this issue is fixed with adding below but I don't get any callbacks after update to 1.12.13+hotfix.6. This should be reopened.
if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate }
Removing those lines and it works again
@CasperPas, everybody: What would be possible other implications when removing that code?
it's weird because in the documentation it says to put this line it doesn't make sense
it is strange because in the documentation says to put this line, it does not send
Because on previous versions it was required. 6.0.1 and specifically that line from the documentation fixed my app's notifications. I was running flutter 1.9.1 at the time of the fix.
I'm not sure what's caused it to break in the latest version of flutter, but it definitely was supposed to be there when the change was pushed.
everybody: What would be possible other implications when removing that code?
Removing those lines make it work for me. Though as @Cascoid says adding those lines fixed my app notifications when I used 6.0.3, before adding those lines I did not receive any notifications at all...
To summerise:
Removing the following it now works:
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
I am running:
@semone This seems to have solved the issue for me too. I have no idea what these lines of code are supposed to do and if removing them will have any negative impact. Anyone knows?
I tested with Firebase messaging 6.0.9, iOS 10.3.4, and Flutter 1.12.13+hotfix.5
Removing these lines doesn't solve my problem.
Working on Android fine, but doesn't work for iOS in release mode.
I have the next AppDelegate.m:
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
everybody: What would be possible other implications when removing that code?
Removing those lines make it work for me. Though as @Cascoid says adding those lines fixed my app notifications when I used 6.0.3, before adding those lines I did not receive any notifications at all...
To summerise:
Removing the following it now works:if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate }I am running:
- Firebase messaging 6.0.9
- iOS 13.3 and iOS 12.4.4
- Flutter 1.12.13+hotfix.5
You saved me!
if somebody have this issue despite removing this code
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
Than check if you are using in your project flutter_local_notifications. This lib cause not receiving push notifications from firebase on iOS
it was good if the Firebase team updated this in the documentation
Removing the following it now works:
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
To build on @michcio53's answer, if you see flutter_local_notifications in your pubspec.lock file, but don't know where it's coming from, you can run flutter packages deps to spot it.
I am not using _flutter_local_notifications_ But I also had the same issue. As everyone mentioned, removing these lines solved the issue
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
But since the official documentation is against this, I really don't know is there any other side effects for removing this.
CC @collinjackson
everybody: What would be possible other implications when removing that code?
Removing those lines make it work for me. Though as @Cascoid says adding those lines fixed my app notifications when I used 6.0.3, before adding those lines I did not receive any notifications at all...
To summerise:
Removing the following it now works:if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate }I am running:
- Firebase messaging 6.0.9
- iOS 13.3 and iOS 12.4.4
- Flutter 1.12.13+hotfix.5
In what file i need to do this?
Most helpful comment
Removing those lines make it work for me. Though as @Cascoid says adding those lines fixed my app notifications when I used 6.0.3, before adding those lines I did not receive any notifications at all...
To summerise:
Removing the following it now works:
I am running: