Skip to content
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

[firebase_messaging] iOS 13 push notification NOT working #1041

Closed
kroikie opened this issue Oct 13, 2019 · 264 comments
Closed

[firebase_messaging] iOS 13 push notification NOT working #1041

kroikie opened this issue Oct 13, 2019 · 264 comments
Assignees
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: bug Something isn't working

Comments

@kroikie
Copy link
Collaborator

kroikie commented Oct 13, 2019

Push notification does not seem to work on iOS 13 device nor on my iOS 12.4.1 device on stable 1.9.1.
Seems to be 2 separate issues as well.

  1. in Flutter Stable 1.9.1, push notifications do not appear on my iOS 12.4.1 device, when the always worked before on older flutter versions.
  2. iOS 13 device does not receive push notifications at all

Some reading available from oneSignal
https://onesignal.com/blog/ios-13-introduces-4-breaking-changes-to-notifications/

I updated my device OS(personal) version to 13, cannot further test without downgrading it back to 12.4.1. and I do not have a spare iPhone available.

Thank you

Also for other users, can you please input our own issue related to the mentioned.
Things such as current physical device iOS software version and flutter channel along with its version number. so we can compile a list of where in flutter and iOS(versions) things just stopped working.

Push notification is and should be very ### critical part of a persons or companies application when used right. I hope we can address the issues and come up with a solution.

@kroikie
Copy link
Collaborator Author

kroikie commented Oct 13, 2019

@khainhero

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

@BondarenkoStas BondarenkoStas changed the title iOS push notification NOT working. Important. Firebase_messaging, iOS 13 [firebase_messaging] iOS 13 push notification NOT working Oct 21, 2019
@BondarenkoStas BondarenkoStas added impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) type: bug Something isn't working labels Oct 21, 2019
@digarahayu
Copy link

i got same issue ,,, notification only work in foreground,,,, in background not working... there is no notification in tray..

@digarahayu
Copy link

@kroikie
did this problem occur because of Channel stable, v1.9.1+hotfix.5 ?? because #41180 is saw there is people don't get this issue on Flutter (Channel master, v1.10.6-pre.29)

@krille-chan
Copy link

I can confirm this. Notifications are working fine on Android but on iOS all messages are only working in foreground like data messages. They are sent to "onMessage" but in the background nothing happens. When the app is opened again, the missing notifications are sent to "onMessage".

The intention of "notification messages" was to pop them up even when the app is in background or terminated. That doesn't seem to work in iOS at the moment.

@telinx
Copy link

telinx commented Oct 31, 2019

Make sure info.plist is configured

<key>FirebaseScreenReportingEnabled</key>
<true/>
<key>FirebaseAppDelegateProxyEnabled</key>
<true/>

@dopefaceee
Copy link

I'm using flutter stable v1.9.1 and master v1.10.6 and it seems not working at all on ios 13 or 12.4. and yes in android it's working normal.

@digarahayu
Copy link

Not working in android pie up to (emulator)

@njovy
Copy link

njovy commented Nov 4, 2019

I am having this issue on iOS13 as well.

@kitmoovup
Copy link

I have the same issue as well on iOS 13.

@dopefaceee
Copy link

dopefaceee commented Nov 8, 2019

Update:
I've solved the problem with some changes:

  1. FirebaseAppDelegateProxyEnabled from bool NO to string NO
  2. I change my flavor setting with following this link https://medium.com/@matt.goodson.business/separating-build-environment-configurations-in-flutter-with-firebase-doing-it-the-right-way-c72c3ad3621f.
  3. Adding pod 'Firebase/Messaging' to Podfile

Now from console, Push notification had appeared again.

@nashfive
Copy link

nashfive commented Nov 8, 2019

FYI, I've created a simple Flutter app (1.9.1+hotfix.6) with firebase_messaging, and it works as expected on both Android and iOS 13, while the app is in the foreground or the background or killed. I didn't do anything special, besides following the regular steps in the README.

@AlexBacich
Copy link

  1. FirebaseAppDelegateProxyEnabled

@dopefaceee , can you please explain more on your solution? I don't quite understand what exactly you did for each of steps. Where FirebaseAppDelegateProxyEnabled is located? Why you added pod to Podfile if it's managed by pubspec? What exactly was changed in regards of flavoring?

@ThinkSimple
Copy link

FYI, I've created a simple Flutter app (1.9.1+hotfix.6) with firebase_messaging, and it works as expected on both Android and iOS 13, while the app is in the foreground or the background or killed. I didn't do anything special, besides following the regular steps in the README.

It does not work for me...

@dopefaceee
Copy link

dopefaceee commented Nov 9, 2019

@AlexBacich add FirebaseAppDelegateProxyEnabled to your Info.plist.
I add podfile for configuring FIRApp on my AppDelegate.m, so I have to add :
@import Firebase;
and
[FIRApp configure];
before GeneratedPluginRegistrant.
Don't forget to turn on Background Modes and check background fetch, remote notifications.

@AlexBacich
Copy link

AlexBacich commented Nov 12, 2019

FYI, I've created a simple Flutter app (1.9.1+hotfix.6) with firebase_messaging, and it works as expected on both Android and iOS 13, while the app is in the foreground or the background or killed. I didn't do anything special, besides following the regular steps in the README.

Surprisingly, at some point push notifications DID START coming properly. I was able to get normal notifications in background. And then again they STOPPED coming today.

Weird thing about this - how messages are coming. Today format is something like this:

{
  "from": "441854012104",
  "id": "2",
  "notification": {
    "title": "this    is    a    title",
    "body": "this is body"
  },
  "type": "news",
  "click_action": "FLUTTER_NOTIFICATION_CLICK"
}

Yesterday same push (same CURL for sending) had different format:

{
  "from": "441854012104",
  "aps": {
    "alert": {
      "title": "this    is    a    title",
      "body": "this is body"
    }
  },
  "data": {
    "type": "news",
    "id": "2",
    "click_action": "FLUTTER_NOTIFICATION_CLICK"
  }
}

I just don't get it. It's so random.

@nashfive
Copy link

@AlexBacich what you're describing seems to be simply the difference between an Android FCM message and an iOS push :
FCM messages
iOS Push payload

@AlexBacich
Copy link

AlexBacich commented Nov 12, 2019

@nashfive ok, let's take into consideration it's the difference between an Android FCM and iOS Push. But how can I control it? I'm sending exactly the same test request to legacy FCM API and get different message format on my device.
I don't believe in conspirancy but it seems sometimes FCM is sending requests in different format.

@nashfive
Copy link

@AlexBacich hehe... sorry, I don't know why you get different payload then :(
Do you have the same problem when sending test push notifications from Firebase Messaging with a given token ?

@AlexBacich
Copy link

@nashfive yes, problem is exactly when sending with specific push token.

@OsamaFelFel
Copy link

Is there any workaround for this issue?

@IvanOnishchenko
Copy link

For me it was problem with wrong App ID in firebase console, now notifications work.

@OsamaFelFel
Copy link

@IvanOnishchenko is it working on iOS 13?

@IvanOnishchenko
Copy link

IvanOnishchenko commented Nov 16, 2019

@OsamaFelFel Yes, when I send it from firebase Cloud Messaging console, but it still doesn't work for personal notification, when one user sending messages to other.
Actually all is working, it was my mastake.

@michcio53
Copy link

has anyone tested notifications on ios 14?

@acoutts
Copy link

acoutts commented Sep 22, 2020

has anyone tested notifications on ios 14?

Working fine for me so far!

@zfc0812
Copy link

zfc0812 commented Sep 23, 2020

has anyone tested notifications on ios 14?

It's not working for me.

@yakeer
Copy link

yakeer commented Sep 24, 2020

iOS 14, background notifications with FCM doesn't work for mr as well.

Foreground notifications working as expected.
I'm using the Platform.isIOS ? null solution to avoid the exception on load.

@acoutts
Copy link

acoutts commented Sep 24, 2020

iOS 14, background notifications with FCM doesn't work for mr as well.

Foreground notifications working as expected.
I'm using the Platform.isIOS ? null solution to avoid the exception on load.

Try my fix here for swizzling to resolve the background notifications: #3395 (comment)

@yakeer
Copy link

yakeer commented Sep 24, 2020

iOS 14, background notifications with FCM doesn't work for mr as well.
Foreground notifications working as expected.
I'm using the Platform.isIOS ? null solution to avoid the exception on load.

Try my fix here for swizzling to resolve the background notifications: #3395 (comment)

Didn't work for me :/
I don't use firebase auth...

Tried to disable swizzling.. didn't help as well.

@acoutts
Copy link

acoutts commented Sep 24, 2020

iOS 14, background notifications with FCM doesn't work for mr as well.
Foreground notifications working as expected.
I'm using the Platform.isIOS ? null solution to avoid the exception on load.

Try my fix here for swizzling to resolve the background notifications: #3395 (comment)

Didn't work for me :/
I don't use firebase auth...

Tried to disable swizzling.. didn't help as well.

You can use that exact snippet, just comment out the parts about auth. If you disable swizzling, you must implement the calls into the firebase lib as my example does.

@yakeer
Copy link

yakeer commented Sep 24, 2020

iOS 14, background notifications with FCM doesn't work for mr as well.
Foreground notifications working as expected.
I'm using the Platform.isIOS ? null solution to avoid the exception on load.

Try my fix here for swizzling to resolve the background notifications: #3395 (comment)

Didn't work for me :/
I don't use firebase auth...
Tried to disable swizzling.. didn't help as well.

You can use that exact snippet, just comment out the parts about auth. If you disable swizzling, you must implement the calls into the firebase lib as my example does.

Could you please copy here what exactly should be written?
I'm pretty much lost here, and not sure what parts are of the auth..

@yakeer
Copy link

yakeer commented Sep 24, 2020

I tried to put this code,
but with no luck, it compiled but remote notifications were still off :/

// https://firebase.google.com/docs/auth/ios/phone-auth#appendix:-using-phone-sign-in-without-swizzling
// // https://firebase.google.com/docs/cloud-messaging/ios/client#token-swizzle-disabled
// override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

//     // Pass device token to messaging
//     Messaging.messaging().apnsToken = deviceToken
    
//     return super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
// }

// // https://firebase.google.com/docs/auth/ios/phone-auth#appendix:-using-phone-sign-in-without-swizzling
// // https://firebase.google.com/docs/cloud-messaging/ios/receive#handle-swizzle
// override func application(_ application: UIApplication,
//                           didReceiveRemoteNotification notification: [AnyHashable : Any],
//                           fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

//     // Handle it for firebase messaging analytics
//     if ((notification["gcm.message_id"]) != nil) {
//         Messaging.messaging().appDidReceiveMessage(notification)
//     }
    
//     return super.application(application, didReceiveRemoteNotification: notification, fetchCompletionHandler: completionHandler)
// }

@yakeer
Copy link

yakeer commented Sep 25, 2020

I had the Push Notifications permission on iOS plist off, which is weird because I'm pretty sure I turned it on.

Together with @acoutts solution, it worked.

Thanks.

@Levi-Lesches
Copy link
Contributor

Based on everyone who IS getting their app to work, and that it seems to be non-reproducible, is this a bug, or just configuration error?

@acoutts
Copy link

acoutts commented Sep 25, 2020

Based on everyone who IS getting their app to work, and that it seems to be non-reproducible, is this a bug, or just configuration error?

The library works- I know because i've got it working in my app, and I've personally setup the included example app and it also works. The library does have at least one bug though, like the one where data messages are broken when used in combination with Firebase Auth and you have to disable swizzling / manually handle swizzling (my issue / workaround here: #3395 (comment)) to make it work.

That being said, I know they have a rework of firebase_messaging on the roadmap so I think they'll have everything fixed after that. I personally think most of the issues reported in this thread are configuration errors, and I've not seen anyone provide an example project which demonstrates that it's broken.

Until someone can do that, then this issue wont get much attention from the Invertase team.

@DomingoMG
Copy link

@acoutts My application uses Firebase Database Realtime, Firebase Auth, Firebase Messaging.

I have proceeded to perform the steps you indicate but it throws me a compatibility error, I still cannot get the notifications to work on iOS.

#3395 (comment)

@acoutts
Copy link

acoutts commented Sep 27, 2020

@DomingoMG see my comment there- just to confirm, you will want to increase your project to iOS 9 due to Flutter 1.22 now requiring that anyways, so it's best to make that change.

@zeshuaro
Copy link

#2239 (comment)

I used the solution above and notifications are working for me now.

@vanfresh
Copy link

vanfresh commented Oct 5, 2020

For those getting foreground notification but not background, make sure you set apn-push-type=alert header and the corresponding alert config when you push from the server. Once I set it, everything works as expected.

@zfc0812
Copy link

zfc0812 commented Oct 5, 2020

For those getting foreground notification but not background, make sure you set apn-push-type=alert header and the corresponding alert config when you push from the server. Once I set it, everything works as expected.

How to set it from Firebase?

@Evilhexic
Copy link

Evilhexic commented Oct 7, 2020

I had the same Issues. In my case its been solved by checking the following in Xcode:

Runner -> Signing & Capabilities -> Make sure that in all categories (All, Debug, Release, Profile) Background Modes (with Background fetch & Remote notifications) and Push Notifications are added to Capabilities.

After that everything worked without setting any headers in Firebase. (Testing on real iOS device)

Fluter 1.22.0
Xcode 12.0.1
firebase_messaging: ^7.0.2
iOS 14.0.1

@mrtnetwork
Copy link

I'm getting nervous

@SalsabeelaHasan
Copy link

plist

can you share us the steps to turn on Push Notifications permission ?

@mrtnetwork
Copy link

void iOSPermission() {
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true, badge: true, alert: true, provisional: false)); }

@SalsabeelaHasan
Copy link

void iOSPermission() {
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true, badge: true, alert: true, provisional: false)); }

in any file add this code
?

@codefreak13
Copy link

void iOSPermission() {
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true, badge: true, alert: true, provisional: false)); }

in any file add this code
?

please have you had any success? I have the same bug, I receive notifications only on foreground of iOS 13 and 14 but works fine on iOS 11.

@codefreak13
Copy link

I had the Push Notifications permission on iOS plist off, which is weird because I'm pretty sure I turned it on.

Together with @acoutts solution, it worked.

Thanks.

please can you show a detail of the permission you added to plist

@asantainnasa
Copy link

asantainnasa commented Nov 4, 2020

I had the same issue. What finally fixed it for me was to make sure that in firebase cloud messaging settings that I uploaded the p8 APN authentication key. Wala!

For more details I followed this medium article.

Also please make sure in your apple developer portal that your app identifier has apple push services enabled.

@Levi-Lesches
Copy link
Contributor

FCM is being reworked -- soon all this setup may be obsolete

https://twitter.com/mikediarmid/status/1319298281290203139

@Salakar
Copy link
Member

Salakar commented Nov 5, 2020

Hey all 👋

As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues along with detailed documentation on how to setup and also send messages from your backend.

If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.

Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.

Thanks everyone.

@Salakar Salakar closed this as completed Nov 5, 2020
@firebase firebase locked and limited conversation to collaborators Dec 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests