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 devices never receive data-only message #13423

Closed
5 tasks done
Pedrozena opened this issue Sep 28, 2024 · 6 comments
Closed
5 tasks done

[firebase_messaging]: iOS devices never receive data-only message #13423

Pedrozena opened this issue Sep 28, 2024 · 6 comments
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. plugin: messaging resolution: user This was a user issue, e.g. invalid configuration or code. type: bug Something isn't working

Comments

@Pedrozena
Copy link

Pedrozena commented Sep 28, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

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

  • 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?

  • I have an active Apple Developer account.

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

  • 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></key>
	<string></string>
	<key>NSBluetoothServices</key>
	<array>
		<string></string>
	</array>
	<key>CFBundleDisplayName</key>
	<string></string>
	<key>FirebaseDynamicLinksCustomDomains</key>
	<array>
		<string>https://----</string>
	</array>
	<key>LSApplicationCategoryType</key>
	<string></string>
	<key>GADApplicationIdentifier</key>
	<string>ca-app-pub--------</string>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>fbapi</string>
		<string>fb-messenger-api</string>
		<string>fbauth2</string>
		<string>fbshareextension</string>
	</array>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>BGTaskSchedulerPermittedIdentifiers</key>
	<array>
		<string>dev.flutter.background.refresh</string>
	</array>
	<key>CADisableMinimumFrameDurationOnPhone</key>
	<true/>
	<key>CFBundleDevelopmentRegion</key>
	<string>$(DEVELOPMENT_LANGUAGE)</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIconName</key>
	<string>AppIcon</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleName</key>
	<string>.....</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>CFBundleURLSchemes</key>
			<array>
				<string>com.googleusercontent.apps-----</string>
			</array>
		</dict>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>-----</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>------</string>
			</array>
		</dict>
	</array>
	<key>CFBundleVersion</key>
	<string>$(FLUTTER_BUILD_NUMBER)</string>
	<key>FacebookAppID</key>
	<string>-------</string>
	<key>FacebookClientToken</key>
	<string>-------</string>
	<key>FacebookDisplayName</key>
	<string>com.....app</string>
	<key>FirebaseAppDelegateProxyEnabled</key>
	<string>YES</string>
	<key>ITSAppUsesNonExemptEncryption</key>
	<false/>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsLocalNetworking</key>
		<true/>
	</dict>
	<key>NSBluetoothAlwaysUsageDescription</key>
	<string>bluetooth</string>
	<key>NSBluetoothPeripheralUsageDescription</key>
	<string>bluetooth</string>
	<key>NSCameraUsageDescription</key>
	<string>Allow access to camera to capture photos</string>
	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string>This app always needs location and when in use to function</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>This app always needs location to function</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>This app needs location when in use to function</string>
	<key>NSMicrophoneUsageDescription</key>
	<false/>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>App needs access to photo lib</string>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>Allow access to photo library</string>
	<key>UIApplicationSupportsIndirectInputEvents</key>
	<true/>
	<key>UIBackgroundModes</key>
	<array>
		<string>fetch</string>
		<string>processing</string>
		<string>remote-notification</string>
	</array>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UIViewControllerBasedStatusBarAppearance</key>
	<string>true</string>
</dict>
</plist>

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

from firebase_admin import messaging
#firebase-admin           6.5.0

def send_message_to_token(data, token, notification=None):
    data = _convert_data(data)
    apns = None
    android = None
    if notification is not None:
        notification = messaging.Notification(**notification)
    else:
        apns = messaging.APNSConfig(
            payload=messaging.APNSPayload(
                aps=messaging.Aps(content_available=True, custom_data={"gcm.message_id": str(uuid.uuid4())})
            )
        )
        android = messaging.AndroidConfig(priority="high")    
    message = messaging.Message(data, notification=notification, token=token, apns=apns, android=android)
    messaging.send(message, app=get_app())
    logger.info(f"sent message to token: {token}")

Have you requested permission from the user to receive notifications?

  • 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?

No logs are printed so we can't tell if the message was delivered.

Additional context and comments

Android devices receive such messages, and iOS ones receive regular messages with non-null notifications.

While using legacy FCM api with the following payload:

{
  "to": token,
  "priority": "high",
  "content_available": true,
  "data": {
    "new_message": {
      "sender_uid": sender_uid,
      "message_payload": message,
    },
  },
}

the iOS devices regularly received also background messages.

@Pedrozena Pedrozena added Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. plugin: messaging type: bug Something isn't working labels Sep 28, 2024
@Pedrozena Pedrozena changed the title [firebase_messaging]: iOS devices never receive background message [firebase_messaging]: iOS devices never receive data-only message Sep 28, 2024
@SelaseKay
Copy link
Contributor

Hi @Pedrozena , What version of firebase_messaging are you experiencing this on?

@SelaseKay SelaseKay added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Sep 30, 2024
@Pedrozena
Copy link
Author

Hi @SelaseKay. We use:
firebase_messaging: ^15.0.1

@google-oss-bot google-oss-bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Sep 30, 2024
@SelaseKay
Copy link
Contributor

Kindly update to the latest version and try again.

@SelaseKay SelaseKay added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Sep 30, 2024
@Pedrozena
Copy link
Author

updating to version 15.1.3 doesn't solve the issue.

@google-oss-bot google-oss-bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Sep 30, 2024
@Lyokone
Copy link
Contributor

Lyokone commented Oct 2, 2024

Hello @Pedrozena, if you are receiving normal notifications but not data only notifications, it's probably something to do with your setup since we are not doing anything between those 2.
I see that you are using the content_available key, is this the right key for the language you are using? In JS/TS you are supposed to use contentAvailable.
Also Apple doesn't guarantee that data only messages will be delivered, so you can get throttled while debugging this kind of feature.

@Lyokone Lyokone closed this as completed Oct 2, 2024
@Lyokone Lyokone added the resolution: user This was a user issue, e.g. invalid configuration or code. label Oct 2, 2024
@Pedrozena
Copy link
Author

Yes, I'm using the official firebase_admin Python package, and that property is correct.
I opened the related issue there

@firebase firebase locked and limited conversation to collaborators Nov 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. plugin: messaging resolution: user This was a user issue, e.g. invalid configuration or code. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants