Closed kroikie closed 3 years ago
@khainhero
The issue at https://github.com/flutter/flutter/issues/41180 has been closed and moved here. Future collaboration on this issue will be done here.
i got same issue ,,, notification only work in foreground,,,, in background not working... there is no notification in tray..
@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)
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.
Make sure info.plist is configured
<key>FirebaseScreenReportingEnabled</key>
<true/>
<key>FirebaseAppDelegateProxyEnabled</key>
<true/>
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.
Not working in android pie up to (emulator)
I am having this issue on iOS13 as well.
I have the same issue as well on iOS 13.
Update: I've solved the problem with some changes:
Now from console, Push notification had appeared again.
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.
- 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?
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...
@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.
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.
@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
@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.
@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 ?
@nashfive yes, problem is exactly when sending with specific push token.
Is there any workaround for this issue?
For me it was problem with wrong App ID in firebase console, now notifications work.
@IvanOnishchenko is it working on iOS 13?
@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.
@nashfive Hi, may I know your xcode version and the device you used? I use flutter v1.10.6-pre.29
with xcode 11.2.1
and Iphone 11 simulator (iOS 13.2.2), and the FCM I sent from console is received only when the app is in foreground. When it's in background no notifications appeared on the tray.
EDIT: it works on real device
same error with iOS 13
@shenwilly At the moment, we use Bitrise.io with the Xcode 10.3 stack. The app uses Flutter stable 1.9.1 and we get push notifications in the foreground and in the background on our iOS 13 devices.
If I recall, you can't get push notifications on a iOS simulator (besides the foreground ones since the app establishes a direct connection to FCM).
anything new here?
For me it looks like this: 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.
iOS 13.1.1
@liri2006 did you find workaround? I was advised to write own realization of plugin.
@marinat Nope, I've spent a day trying and fiddling with different workaround/suggestions from around the internet, but nothing worked. Hope it will be fixed soon.
@liri2006 maybe it makes sense to create a new issue with your description?
@marinat Well, most probably my issue is also related to iOS 13 changes to push notifications (I have no device with older version to prove it wrong), so I see no reason to create yet another issue (and there is already few of them related to problem of not receiving messages on iOS devices), cuz most likely it will be closed anyway.
But if you have same issue and think it could help - feel free to copy paste my description :)
firebase_messaging 6.0.3. The Issue has remained for me. Messages are ignored by onMessage (or any other callback).
@liri2006 I faced with same issue on ios 12.4.3, so, I don't think that it related to iOS 13
Having the same issues but I noticed that in the onMessage method, the function "stops" as soon as I try to get data from the message (reportin no Flutter error)
This:
onMessage: (Map<String, dynamic> message) async {
print("New notification");
String url = message["data"]["url"];
String sender = message["data"]["sender"];
String descr = message["data"]["description"];
print("New notification from $sender");
}
prints only "New notification".
Is there any change ?
Can someone post a version of firebase_messaging that works on both iOS and Android?
None of solutions working for me. I am using flutter v1.12.13+hotfix.6 and 6.0.9.
I opened a new issue as the original issue isn't related. I am having the exact same problem as @liri2006 said.
Im getting notifications in the foreground while the app is open on a real devices 12.4 and 13.2. I have spent all day trying to get it to work in the background. I have all the settings defined. I used to have this working and I changed my bundle id (I have reconfigured the firebase for this) I can see the notifications show in the console after the app is opened but the never show up in the notifications tray or notification dots.
Does anyone have any ideas?
Also can someone show me how this is supposed to be added to the file specified. Where in the file?
if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate }
@KCWebmaster that is is my appdelegate file written in Swift:
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Hope it will help you in my case notifications works only in the background, but not in the foreground
I also do not get any or proper callbacks if app is active for iOS.
Sending notifications from Firebase console with notification data. NOTE: Not a data only message.
Active:
Terminated:
Interesting output from plugin when running in xcode and receiving a message when active in foreground (with no dart callback triggered):
2019-12-17 14:54:06.734150+0100 Runner[656:142634] 6.0.0 - [Firebase/Messaging][I-FCM006000] Received message missing local start time, dropped.
Weird fact: iOS simulator is the exact opposite: only the active - in foreground - onMessage callback is working.
Using plugin version 6.0.1
[✓] Flutter (Channel master, v1.13.3-pre.23, on Mac OS X 10.15.1 19B88, locale en-SE)
• Flutter version 1.13.3-pre.23 at /Users/fredrik.dahlen/DEV/flutter
• Framework revision c06bf6503a (4 days ago), 2019-12-13 17:42:35 -0500
• Engine revision e0e0ac0a68
• Dart version 2.8.0 (build 2.8.0-dev.0.0 45db297095)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/fredrik.dahlen/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /Users/fredrik.dahlen/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.35.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.1.0
[✓] Connected device (3 available)
• Fredrik’s iPhone • f6414d51c92a4d1e13c55cc0b2b04547651d022b • ios • iOS 13.3
• iPhone 6 • C19DB004-0380-4514-8FF0-02567CD522AB • ios • com.apple.CoreSimulator.SimRuntime.iOS-10-3 (simulator)
• iPhone 11 Pro Max • 2CB4F96D-6F12-43ED-9ECC-069D757D164B • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• No issues found!
@DjivaCanessane Thank you. I wonder why you have the opposite for your notifications.
Just to be clear, what is the minimum correct structure of the FMC payload be in order for onResume callback to fire? Documentation is very lacking here. Like do we have to set 'priority' to high or something? I'm getting notifications from this payload: notification: { title: '', body: 'jim started following you.' }, data: { click_action: 'FLUTTER_NOTIFICATION_CLICK', title: '', body: 'jim started following you.', screen: 'user', extradata: 'extraData' },
But I cannot access the data since onResume will not fire.
Tested on iOS 13.
I'm also having a hard time trying to make it work. Messages while app is in background are shown but when it's in foreground they're not, looks like onMessage
doesn't trigger.
Also callbacks are not fired when tapping the notification. I am running iOS 13.
This is my payload, I'm using admin.messaging
SDK from NodeJS. I put click_action
and category
everywhere to try luck but obviously didn't work 😆 .
payload: {
notification: {
title: "test",
body: "test",
android_channel_id: "test",
click_action: "FLUTTER_NOTIFICATION_CLICK",
category: "FLUTTER_NOTIFICATION_CLICK",
},
data: {
type: pushType.toString(),
userId: userId,
click_action: "FLUTTER_NOTIFICATION_CLICK",
referenceId: referenceId,
category: "FLUTTER_NOTIFICATION_CLICK",
},
},
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.
I want to add to this. I'm experiencing the same situation: different devices receive different payloads. I have a bunch of iphones - an SE, an XR, an XS and a few androids. Androids all work fine, iPhones some work ok, but two of them receive a different payload with the push notification image.
It is not a backend issue, we checked. In our investigation, we tried sending messages from Firebase console while including the click_action: FLUTTER_NOTIFICATION_CLICK pair in the custom data object and same result: some devices work, some don't. Those that don't receive payloads with no "data" / "custom_data" objects in them. How is that even possible?
@old-reynard I had the exact same issue. We stopped getting notifications when we were installing on iOS directly from the Macbook instead of from testflight. I'm not 100% sure why this happened, but I think it's because you can't get FCM in an emulator.
When I send a message from the Firebase Console to all devices i'm getting the notification on my iOS devices. However when I send a message through the app targeted to specific users its just not working at all, onMessage, onLaunch & onResume are not fired at all! Is anyone else experiencing this? Could someone possibly share an example message payload to send? the way i'm sending works for android and had worked previously on iOS
I also do not get any or proper callbacks if app is active for iOS.
Sending notifications from Firebase console with notification data. NOTE: Not a data only message.
Active:
- in foreground -> nothing (no callback from plugin whatsoever) FAIL
- in background -> tray notification received, but when clicked app is opened but with no callback. FAIL
Terminated:
- tray notification - and when clicked the onLaunch callback is triggered (with kind of weird data, but that is another story) WORKING
Interesting output from plugin when running in xcode and receiving a message when active in foreground (with no dart callback triggered):
2019-12-17 14:54:06.734150+0100 Runner[656:142634] 6.0.0 - [Firebase/Messaging][I-FCM006000] Received message missing local start time, dropped.
Weird fact: iOS simulator is the exact opposite: only the active - in foreground - onMessage callback is working.
Using plugin version 6.0.1
[✓] Flutter (Channel master, v1.13.3-pre.23, on Mac OS X 10.15.1 19B88, locale en-SE) • Flutter version 1.13.3-pre.23 at /Users/fredrik.dahlen/DEV/flutter • Framework revision c06bf6503a (4 days ago), 2019-12-13 17:42:35 -0500 • Engine revision e0e0ac0a68 • Dart version 2.8.0 (build 2.8.0-dev.0.0 45db297095) [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/fredrik.dahlen/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME = /Users/fredrik.dahlen/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 11.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3, Build version 11C29 • CocoaPods version 1.8.4 [✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 42.1.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) [✓] VS Code (version 1.35.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.1.0 [✓] Connected device (3 available) • Fredrik’s iPhone • f6414d51c92a4d1e13c55cc0b2b04547651d022b • ios • iOS 13.3 • iPhone 6 • C19DB004-0380-4514-8FF0-02567CD522AB • ios • com.apple.CoreSimulator.SimRuntime.iOS-10-3 (simulator) • iPhone 11 Pro Max • 2CB4F96D-6F12-43ED-9ECC-069D757D164B • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator) • No issues found!
UPDATE:
I removed the native code changes that the documentation instructions suggests. This part:
// removed
if (@available(iOS 10.0, *)) {
[UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>) self;
}
Now everything works as intended. Weird.
Other changes I had to do (not directly related): Not registering onBackgroundMessage callback if iOS in the plugin configure code (otherwise it fails).
onBackgroundMessage: Platform.isIOS ? null : backgroundMessageHandler,
Tested with version 6.0.9 (latest) of the plugin. @bparrishMines please advise.
yes, I had the same issue and after removing the flowing code, everything worked fine.
// removed
if (@available(iOS 10.0, *)) {
[UNUserNotificationCenter currentNotificationCenter].delegate = (id
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.