flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_messaging]: Messaging stopped working properly after firebase update

Open pamafe1976 opened this issue 1 year ago β€’ 22 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Are you aware of the differences between iOS and Android background message handling?

  • [X] I understand that iOS and Android background messages behave differently, and I've designed my application with that in mind.

Do you have an active Apple Developer account?

  • [X] I have an active Apple Developer account.

Are you using a physical iOS device to test background messages?

  • [X] I am using a physical iOS device to test background messages.

Have you enabled "Remote Notifications" & "Background Mode" (Checking options for "Background Processing" & "Remote Notifications") in your app's Xcode project?

image

Have you created an APNs key in your Apple Developer account & uploaded this APNs key to your Firebase console?

image

Have you disabled method swizzling for Firebase in your app?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CADisableMinimumFrameDurationOnPhone</key>
	<true/>
	<key>CFBundleDevelopmentRegion</key>
	<string>$(DEVELOPMENT_LANGUAGE)</string>
	<key>CFBundleDisplayName</key>
	<string>CatedralApp</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>catedralapp</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>$(FLUTTER_BUILD_NAME)</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>com.googleusercontent.apps.730634363046-ibebsa45r1d8v889vt1smtivfp64475g</string>
			</array>
		</dict>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>BundleID</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>com.pmf.catedralappios</string>
			</array>
		</dict>
	</array>
	<key>CFBundleVersion</key>
	<string>$(FLUTTER_BUILD_NUMBER)</string>
	<key>GADApplicationIdentifier</key>
	<string>ca-app-pub-1785464071070677~7221440751</string>
	<key>GIDClientID</key>
	<string>730566337046-ibebsa45r1d8v889vt1smtivfp04233g.apps.googleusercontent.com</string>
	<key>LSApplicationCategoryType</key>
	<string></string>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>sms</string>
		<string>tel</string>
	</array>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string>We need to access your location while the app is in the background, This will allow CatedralApp to give you instructions and record your tracks even when your phone is in your pocket.</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>We need to access your location while the app is in the background. This will allow CatedralApp to give you instructions and record your tracks even when your phone is in your pocket.</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>We need to access your location in order to show your position on the resort map.</string>
	<key>PermissionGroupNotification</key>
	<string>Notification</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>The application does not use this permission</string>
	<key>UIApplicationSupportsIndirectInputEvents</key>
	<true/>
	<key>UIBackgroundModes</key>
	<array>
		<string>audio</string>
		<string>fetch</string>
		<string>location</string>
		<string>remote-notification</string>
	</array>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UIStatusBarHidden</key>
	<false/>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UIViewControllerBasedStatusBarAppearance</key>
	<false/>
	<key>FirebaseDynamicLinksCustomDomains</key>
	<array>
		<string>https://catedralapp.com.ar/shares</string>
	</array>
	<key>FirebaseDeepLinkPasteboardRetrievalEnabled</key>
	<false/>
	<key>FirebaseAutomaticScreenReportingEnabled</key>
	<false/>
</dict>
</plist>

Are you sending messages to your app from the Firebase Admin SDK?

def enviarTest():
    msg = messaging.Message(topic='test', data={
        'foo': 'bar', 'topic': 'test'}, apns=messaging.APNSConfig(
        payload=messaging.APNSPayload(
            aps=messaging.Aps(content_available=True)),
    ),)
    messaging.send(msg)
    return None

Have you requested permission from the user to receive notifications?

  • [X] I have the relevant permission to receive notifications.

Have you used the 'Console' application on your macOS device to check if the iOS device's system is throttling your background messages?

Im attaching different cases:

  1. With BOM 1.1.0, background message correctly delivered to app link to content
  2. With BOM 2.0.0, foreground message is not delivered link to content
  3. With BOM 2.0.0, background message is not delivered link to content
  4. With BOM 2.0.0, if I add badge to the message, foreground is delivered but background not link to content

Additional context and comments

Im using firebase messaging in a flutter app. Everything works fine (foreground and background messages are correctly received) if I revert to versions from 2024-05-28 - [BoM 1.1.0]

However if I go to a version equal or greater than 2024-06-04 - [BoM 2.0.0] messaging stops working, both foreground and background. I have found that foreground works if I add a badge number to the message, but I dont understand why.

Background messages are not delivered to the app even when badge is present. I have tried both with and without setting content_available=True. In BOM 1.1.0 works fine regardless of this setting, and in BOM 2.0.0 and above does not deliver the background messages at all.

Regards

pamafe1976 avatar Sep 07 '24 16:09 pamafe1976

Eventough the messages are received at first with BOM 1.1.0 both in foreground and background, after some time of being in background the messages are not delivered anymore. May be a battery protection in iOS.

pamafe1976 avatar Sep 11 '24 13:09 pamafe1976

Same issue facing while trying to send notification from flutter client(Android), iOS client, firebase cloud function using admin SDK. All were working few days back, suddenly stoped working.

mdrakib19 avatar Sep 12 '24 10:09 mdrakib19

@mdrakib19 Did you upgrade firebase packages before that started to happen?

pamafe1976 avatar Sep 12 '24 12:09 pamafe1976

I have the same problem: notifications were working fine the last few days, but now my app isn't receiving notifications on either iOS or Android.

KosmosD06000 avatar Sep 12 '24 14:09 KosmosD06000

can you switch content_available=True to content-available=1 for iOS

Fugipe avatar Sep 13 '24 08:09 Fugipe

@pamafe1976 no I didn't. It's suddenly stopped working. I was using legacy API to send the push from the clients. Now I am switching to cloud function and sending push using admin SDK and it's working. I guess legacy API stopped working and we have to switch V1.

mdrakib19 avatar Sep 15 '24 06:09 mdrakib19

I have the same problem: notifications were working fine the last few days, but now my app isn't receiving notifications on either iOS or Android.

Same here!

Luismi74 avatar Sep 16 '24 14:09 Luismi74

@Luismi74 https://firebase.google.com/docs/cloud-messaging/migrate-v1

Fugipe avatar Sep 16 '24 14:09 Fugipe

I believe I reported similar problem, here are my findings: https://github.com/firebase/flutterfire/issues/13350

looks like all tokens, created with version < 15.0.0 stopped working. And we are not using legacy API, even Firebase Messaging "Send test message" feature is not working properly with tokens generated with SDK <15.0.0. It is really suprising for me, I do believe it is a huge inpact.

Rovalx avatar Sep 17 '24 21:09 Rovalx

Enable method Swizzling for iOS did the trick for me!

<key>FirebaseAppDelegateProxyEnabled</key> <false/>

Juliusvm avatar Sep 19 '24 10:09 Juliusvm

I'm unable to reproduce this on firebase_messaging 15.1.2. Kindly bump your firebase_messaging version and try again. I'll be awaiting feedback.

SelaseKay avatar Sep 19 '24 12:09 SelaseKay

I'm unable to reproduce this on firebase_messaging 15.1.2. Kindly bump your firebase_messaging version and try again. I'll be awaiting feedback.

~~It still doesn't work for me.~~

~~Same issue as @pamafe1976.~~

~~For me, after updating to Xcode 16, my project can't build with BoM 1.1.0. Therefore, I had to upgrade Flutter to version 3.24 and use BoM 2.8.0. However, after that, Messaging stopped working.~~

~~I have two MacBooks with different Xcode versions. On Xcode 15, BoM 1.1.0 works fine with FCM.~~

After I reset my iPhone to factory settings, it’s working now (tested on iOS 18.1 DB4, though I’m not sure why it works).

l3lackMegas avatar Sep 20 '24 12:09 l3lackMegas

I have some Firebase Messaging push campaigns that stopped working as well since 16th September. Captura de Tela 2024-09-23 aΜ€s 10 41 00 Is there any way to solve this for users in production?

GuiEdington avatar Sep 23 '24 13:09 GuiEdington

I had a similar problem. In my spring service, I upgraded the firebase version in Pom from 9.1.1 to 9.2.0 and when sending messages to firebase, I changed the method from sendAllAsync to sendEachAsync and notifications started arriving. Maybe this will help someone.

DamianGossFirmao avatar Sep 25 '24 13:09 DamianGossFirmao

Also having issues with newer versions of firebase_messaing. Not 100% sure my issue is the same or related though. I've only tested iOS 18 devices.

iOS Flutter app with BoM 2.4.1 works, any later versions doesn't work. The biggest change made in later versions is switching from iOS SDK 10.29 (used in BoM 2.4.1) to iOS SDK 11.0 (used in BoM 2.5.0) A major version jump of the iOS SDK that seems to have broken something between firebase_messaging 15.0.4 and 15.1.0.

Disabling method swizzling and adding the following to AppDelegate.swift makes it work, but I don't want to do that since it's not recommended.

func application(_ application: UIApplication,
    didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  Messaging.messaging().apnsToken = deviceToken;
}

Daniel-BD avatar Oct 03 '24 09:10 Daniel-BD

I'm unable to reproduce this on firebase_messaging 15.1.2. Kindly bump your firebase_messaging version and try again. I'll be awaiting feedback.

Hi @SelaseKay, I have tested once again just in case, updating firebase_messaging to 15.1.3 I confirm that after the update, the messages are not being received anymore in IOS, both in foreground or background. Android keep working with no issue.

If I go back to firebase_messaging 14.9.4, messages are received perfectly in both platforms, both in foreground and in background.

pamafe1976 avatar Oct 09 '24 00:10 pamafe1976

We are experiencing the same issue when using the messaging.send(msg) with no Notification.title. We would still receive messages for Android and Web, but not iOS.

As a workaround we now use a MulticastMessage and specify a title, eg.

	var message: MulticastMessage = {
		notification: { title: '...' },
		data: {
                    ...
		},
		tokens: [{fcmToken}]
	};

await getMessaging().sendEachForMulticast(message)

At least this works for us now.

minusoneman avatar Oct 14 '24 05:10 minusoneman

Hi @minusoneman,

If you include the notification field in messaging.send does it work on IOS? I cant use MulticastMessage because I need to send the message to a topic.

Regards

pamafe1976 avatar Oct 14 '24 17:10 pamafe1976

@pamafe1976 We didn't test messaging.send() with notification.title. We already had MulticastMessage working in our app, so we just changed our server functions to only use MulticastMessage and that worked so we left it at that. It would be interesting to test, though.

minusoneman avatar Oct 15 '24 00:10 minusoneman

it work if change back to old version ` firebase_messaging: 14.9.4

firebase_core: 2.32.0

cloud_firestore: 4.17.5

firebase_storage: 11.7.7 `

mminhlequang avatar Oct 15 '24 03:10 mminhlequang

@mminhlequang Yes, it works fine when reverting to old version. Thats the reason I opened the issue.

Good be great to have someone in the Firebase team look into this to find out if something was inadvertenly broken at some point.

pamafe1976 avatar Oct 15 '24 12:10 pamafe1976

@pamafe1976 We didn't test messaging.send() with notification.title. We already had MulticastMessage working in our app, so we just changed our server functions to only use MulticastMessage and that worked so we left it at that. It would be interesting to test, though.

Including notification title would not be an option in my case, since the notification would be shown to the user by the OS, and I want the message to be invisible to the user, because it contains data that is to be processed by the app.

pamafe1976 avatar Oct 16 '24 20:10 pamafe1976

Hey @pamafe1976, I have a fix for background message handling in iOS that should allow you to turn FirebaseAppDelegateProxyEnabled back to true.

Could you try this branch: https://github.com/firebase/flutterfire/pull/13525, and let me know if it works for you?

Thanks πŸ™

russellwheatley avatar Oct 21 '24 11:10 russellwheatley

Hey @pamafe1976, I have a fix for background message handling in iOS that should allow you to turn FirebaseAppDelegateProxyEnabled back to true.

Could you try this branch: #13525, and let me know if it works for you?

Thanks πŸ™

HI @russellwheatley

Your PR seems to solve the issue. πŸ’ͺ I have tested my case with your branch, and the messages arrive correctly in IOS, both in foreground and background. Hope it is merged asap!

Regards & Thank you

pamafe1976 avatar Oct 21 '24 21:10 pamafe1976

Hi, is there any news about the new version release? I need to use the previous major firebase_messaging version to get push notifications to work properly.

apaolino avatar Nov 05 '24 07:11 apaolino