Skip to content

Firebase messaging onResume and onMessage broken on iOS since Flutter 1.7.4 #1056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kroikie opened this issue Oct 13, 2019 · 29 comments
Closed
Labels
type: bug Something isn't working

Comments

@kroikie
Copy link
Collaborator

kroikie commented Oct 13, 2019

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)

@kroikie
Copy link
Collaborator Author

kroikie commented Oct 13, 2019

@JaspervanRiet

The issue at flutter/flutter#36201 has been closed and moved here. Future collaboration on this issue will be done here.

@qstuff
Copy link

qstuff commented Oct 17, 2019

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

@JaspervanRiet
Copy link

JaspervanRiet commented Oct 17, 2019

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.

@BondarenkoStas BondarenkoStas added type: bug Something isn't working severe: regression labels Oct 21, 2019
@reecepm
Copy link

reecepm commented Oct 29, 2019

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:
#121
May be related and be the solution to the issue we're having.

@mzaka
Copy link

mzaka commented Oct 29, 2019

Hi guys, Any solutions to this yet ?

@kroikie
Copy link
Collaborator Author

kroikie commented Oct 30, 2019

This issue does seem to be related to #121 which should resolve it.

@reecepm
Copy link

reecepm commented Nov 1, 2019

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!

@njovy
Copy link

njovy commented Nov 4, 2019

Ahh I just found out this issue until now I thought I've been doing wrong as it works intended on Android.

@kroikie
Copy link
Collaborator Author

kroikie commented Nov 25, 2019

Closing now that #121 is merged.

@kroikie kroikie closed this as completed Nov 25, 2019
@liri2006
Copy link

liri2006 commented Dec 4, 2019

@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)

@njovy
Copy link

njovy commented Dec 14, 2019

@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
}

@WahibAbdul
Copy link

@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.

@semone
Copy link

semone commented Dec 20, 2019

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.

@insinfo
Copy link

insinfo commented Dec 22, 2019

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.

@jbxbergdev
Copy link

Same behaviour here with Flutter 1.12.13+hotfix.5 and iOS 13.3. - onResume and onMessage don't fire. Please reopen @kroikie @BondarenkoStas 🙏

@BansookNam
Copy link

BansookNam commented Dec 24, 2019

Same behavior here. on
ios 13.1.3
flutter 1.12.13+hotfix.5

@CasperPas
Copy link

CasperPas commented Jan 6, 2020

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

@jbxbergdev
Copy link

jbxbergdev commented Jan 6, 2020

@CasperPas, everybody: What would be possible other implications when removing that code?

@insinfo
Copy link

insinfo commented Jan 6, 2020

it's weird because in the documentation it says to put this line it doesn't make sense

@reecepm
Copy link

reecepm commented Jan 6, 2020

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.

@semone
Copy link

semone commented Jan 7, 2020

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

@faustinoribeiro
Copy link

@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

@lxpdd
Copy link

lxpdd commented Jan 11, 2020

Removing these lines doesn't solve my problem.
Working on Android fine, but doesn't work for iOS in release mode.

  • Flutter 1.12.13+hotfix.5
  • firebase_messaging: ^6.0.9
  • iOS 12.4.4
  • Deployment target iOS = 9.0

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

@joco-ding
Copy link

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!

@michcio53
Copy link

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

@insinfo
Copy link

insinfo commented Jan 15, 2020

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
}

@stevenspiel
Copy link

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.

@rahulraj64
Copy link

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

@ferso
Copy link
Contributor

ferso commented Apr 30, 2020

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?

@firebase firebase locked and limited conversation to collaborators Aug 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests