-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Cloud Messaging: flutter firebase background notification not working for iOS #16878
Comments
Duplicate of #16853 |
has this error been resolved? |
Hi @MuhammedEminK, apologies for linking the wrong issue earlier. This issue was raised recently and seems to have been resolved. I'm unable to reproduce this issue on my end with the current |
any update ? |
I am also facing same issue. I am also not able to receive notifications on iOS. |
Many people are saying that this issue can't be resolved, but it's been over two months and it's still not fixed. I wonder what the Flutter team is doing about it. |
Hey @MuhammedEminK. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
I just tried it on iPhone 11 Pro, iOS version 18.1.1, it runs normally in debug mode, but doesn't work in release mode |
Hey, I am also facing the same issue, background notification cant be accessed, means the notification is coming but I can't handle that notification using Firebase background handler |
Hi all, how are you confirming that the background handler is not being triggered? I encountered a similar issue while testing in release mode on iOS. Initially, I thought the handler wasn't working because my print statements weren't being executed. After further investigation, I discovered this is a known Flutter issue. It seems that Let me know if this helps. |
what kind of information |
Hi @MuhammedEminK, could you confirm if this applies to your case? |
@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print("Handling a background message: ${message.messageId}");
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
String receiverId = message.data['receiverId'];
print("Receiver ID: $receiverId");
// Update home widget
await SnapApi().updateHomeWidget(receiverId: receiverId);
WidgetsBinding.instance.addPostFrameCallback((_) async {
print("Creating notification in background");
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: DateTime.now().millisecondsSinceEpoch.remainder(100000),
channelKey: 'Mesaj',
title: "Deneme",
body: "Deneme",
// Add any additional data from message.data
),
);
});
} I ran it on iOS 15.8 in version mode and saw the print output in the Xcode console and got the 'Deneme Deneme' notification, but it didn't work in the emulator. I couldn't try it on iOS 17, 18 in realse mode |
Which emulator did you use for testing? |
I used iPhone 15 iOS 17.0, iPhone 15 iOS 17.5, iPhone 16, iPhone 16 Plus, and iPhone 16 Pro iOS 18.1 for testing. |
I've just tried on a real device in release mode, background notifications work. |
have you tried the following step:
|
Hey, thanks for your suggestion, yeah the notifications are working in
background but I want to handle the notification in background, meaning
basically something like when notification comes in background the wifi
settings gets open and all !!
…On Sat, Jan 11, 2025 at 1:45 PM Fransdhinta D. Prianggoro < ***@***.***> wrote:
I've just tried on a real device in release mode, background notifications
work.
have you tried the following step:
1. run with release mode.
2. Terminate app.
3. Open it by tapping the app icon.
4. minimize (background)
5. Send a push notification with a data-only payload, without
notification.
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4L6NTPM3O3Z3GOVGDL2KDHJDAVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBVGE2DENBRGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
yes the problem is we want to do something when we get a background notification, but the background notification listener |
Yeah, my main issue is just that the notification is not benign handled in
background(when app is completely closed). I also tried sending the
notification through Payload and not the notification. And basically I am
using the Flutter Framework, I think Flutter is not getting initialized
when App is terminated. Any solution for the same ??
On Sun, Jan 12, 2025 at 6:10 PM Fransdhinta D. Prianggoro <
***@***.***> wrote:
… Hey, thanks for your suggestion, yeah the notifications are working in
background but I want to handle the notification in background, meaning
basically something like when notification comes in background the wifi
settings gets open and all !!
… <#m_-4809893989827370764_>
On Sat, Jan 11, 2025 at 1:45 PM Fransdhinta D. Prianggoro < *@*.*> wrote:
I've just tried on a real device in release mode, background notifications
work. have you tried the following step: 1. run with release mode. 2.
Terminate app. 3. Open it by tapping the app icon. 4. minimize (background)
5. Send a push notification with a data-only payload, without notification.
— Reply to this email directly, view it on GitHub <#16878 (comment)
<#16878 (comment)>>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/BNXWG4L6NTPM3O3Z3GOVGDL2KDHJDAVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBVGE2DENBRGQ
<https://github.com/notifications/unsubscribe-auth/BNXWG4L6NTPM3O3Z3GOVGDL2KDHJDAVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBVGE2DENBRGQ>
. You are receiving this because you commented.Message ID: @.*>
yes the problem is we want to do something when we get a background
notification, but the background notification listener is not triggered,
the steps I have given above are to reproduce this problem.
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4PI6NSJM72MQPMXDPD2KJPC3AVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBVG4YTQNJRGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
in my case i was developing a phone call feature, so i ended up implementing voip push handling on native side and connected it with flutter side |
Thanks for your input and suggestions, I was assuming that print statement
will be printed but that's not possible because the app gets disconnected
in debug mode and we are not able to track the statements, due to which I
tried to do something on the notification incoming but that also not
working, any other solution.
…On Thu, Jan 2, 2025 at 6:49 PM Jude Selase Kwashie ***@***.***> wrote:
Hi all, how are you confirming that the background handler is not being
triggered? I encountered a similar issue while testing in release mode on
iOS. Initially, I thought the handler wasn't working because my print
statements weren't being executed. After further investigation, I
discovered this is a known Flutter issue
<flutter/flutter#154657>.
It seems that print statements might not function correctly in release
mode, which could lead to the assumption that the handler isn't triggered.
If you're relying on print statements to verify the handler's execution,
this might be the root cause of your issue.
Let me know if this helps.
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4MNHUA2HTWBPOMRNML2IU4H7AVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRXG43DINRUG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I am also working on phone call feature when notification arrives the phone
call is triggered, I think that why to use the native side when using the
Flutter framework that's the last solution, there might be any way that we
can handle the background notification in flutter.
If you want the Android part I have done that part if needed let me know!
On Thu, Jan 16, 2025 at 8:37 AM Fransdhinta D. Prianggoro <
***@***.***> wrote:
… Yeah, my main issue is just that the notification is not benign handled in
background(when app is completely closed). I also tried sending the
notification through Payload and not the notification. And basically I am
using the Flutter Framework, I think Flutter is not getting initialized
when App is terminated. Any solution for the same ??
On Sun, Jan 12, 2025 at 6:10 PM Fransdhinta D. Prianggoro <
*@*.***> wrote:
… <#m_-6330900389538043595_>
in my case i was developing a phone call feature, so i ended up
implementing voip push handling on native side and connected it with
flutter side
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4KMDUQEVNUHNL5QQYL2K4O6DAVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJUGM3TSMBXGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Thank you everyone for your suggestions, but I tried each and every thing
but I am unable to handle the background notification basically when the
app is fully terminated, still working on it. Please let me know if there
are any further updates.
…On Thu, Jan 2, 2025 at 6:49 PM Jude Selase Kwashie ***@***.***> wrote:
Hi all, how are you confirming that the background handler is not being
triggered? I encountered a similar issue while testing in release mode on
iOS. Initially, I thought the handler wasn't working because my print
statements weren't being executed. After further investigation, I
discovered this is a known Flutter issue
<flutter/flutter#154657>.
It seems that print statements might not function correctly in release
mode, which could lead to the assumption that the handler isn't triggered.
If you're relying on print statements to verify the handler's execution,
this might be the root cause of your issue.
Let me know if this helps.
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4MNHUA2HTWBPOMRNML2IU4H7AVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRXG43DINRUG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
thanks, i have no problem for implementation in android, for iOS as i mentioned above i managed to handle background notifications by implementing voip push handling in native side and connecting it to flutter via method channel, let me know if you want the implementation details |
Yeah for sure, means you are triggering a call from the native side only
when the app is in background or always ??
On Thu, Jan 16, 2025 at 11:50 AM Fransdhinta D. Prianggoro <
***@***.***> wrote:
… I am also working on phone call feature when notification arrives the phone
call is triggered, I think that why to use the native side when using the
Flutter framework that's the last solution, there might be any way that we
can handle the background notification in flutter.
If you want the Android part I have done that part if needed let me know!
On Thu, Jan 16, 2025 at 8:37 AM Fransdhinta D. Prianggoro <
*@*.***> wrote:
… <#m_-6998103889192419830_>
thanks, i have no problem for implementation in android, for iOS as i
mentioned above i managed to handle background notifications by
implementing voip push handling in native side and connecting it to flutter
via method channel, let me know if you want the implementation details
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4NIDAPOZ2LIZSZNJO32K5FSDAVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJUGYZDINRVGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
always from native side |
facing same issue here. |
I too don't receive any data-only payloads in my Flutter app. At this point in the code, calling the Line 522 in 9911deb
This is due to the Lines 243 to 247 in 9911deb
I don't think I have enough knowledge on native development to open PR and do the fix properly. I'll leave it to someone else Hope this helps |
Thanks, I'll look into it.
…On Mon, 20 Jan 2025, 21:12 ndelanou, ***@***.***> wrote:
I too don't receive any data-only payloads in my Flutter app.
After some digging, I think I found the cause of this issue:
At this point in the code, calling the _channel variable returns null and
nothing is sent through the channel.
https://github.com/firebase/flutterfire/blob/9911deb61b5a658981a11067154ccf3befce636c/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m#L522
This is due to the didReceiveRemoteNotification handler not being called
from the FLTFirebaseMessagingPlugin but from the AppDelegate. The method
is actually "inserted" via selector here:
https://github.com/firebase/flutterfire/blob/9911deb61b5a658981a11067154ccf3befce636c/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m#L243-L247
I don't think I have enough knowledge on native development to open PR and
do the fix properly. I'll leave it to someone else
Hope this helps
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4MXQEEQ27JZXV2L2O32LUKN3AVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMBSG42DAMJVGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I am also facing same issue and after some digging, I have found that Lines 191 to 193 in 9eac89e
|
Yeah, any other solution you know regarding this, through which we can
handle the notification in background in iOS.
…On Wed, Jan 22, 2025 at 5:08 PM Manoj ***@***.***> wrote:
I am also facing same issue and after some digging, I have found that
onBackgroundMessage is only call for Android platform.
https://github.com/firebase/flutterfire/blob/9eac89ebf1faa16966733bc527fb17c66efac654/packages/firebase_messaging/firebase_messaging_platform_interface/lib/src/method_channel/method_channel_messaging.dart#L191-L193
—
Reply to this email directly, view it on GitHub
<#16878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNXWG4NHL5OYBB5CB4RUP4T2L57J7AVCNFSM6AAAAABTT5BNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMBXGAYDSMZUHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Is there an existing issue for this?
Which plugins are affected?
Messaging
Which platforms are affected?
iOS
Description
I’m implementing Firebase Cloud Messaging (FCM) in my Flutter app to handle push notifications. However, I’ve encountered the following issue:
I have looked all of the other questions and answers but I couldn't solve my problem even I try everything
Reproducing the issue
main.dart
AppDelegate.swift
data
info.plist
I try
but not work
Firebase Core version
3.8.0
Flutter Version
3.24.5
Relevant Log Output
No response
Flutter dependencies
Expand
Flutter dependencies
snippetAdditional context and comments
How can I fix it?
The text was updated successfully, but these errors were encountered: