skip to Main Content

regards documentation of Firebase I have (I suppose) collapsible message.
I had a similar problem with Android, but after removing the whole notification object from the payload it started working.
But on iOS sending notification with (only) data as payload nothing helped – only last notification appears after switching network from offline to online.

Honestly, I tried many different ways (with or without apns header, without apns etc.) and I see a dead end. Help!

For now, my payload looks:

message: {
  token: 'some token',
  data: {
    title: 'some title',
    body: 'some body',
    content_available: 'true',
    priority: 'high'
  }
}

And I’m sending using Rest API

I’m using:

System:
    OS: macOS 12.7.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 3.49 GB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v16.17.1/bin/npm
    Watchman: 2024.01.22.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.15.2 - /Users/darek/.rvm/gems/ruby-2.6.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.3 AI-223.8836.35.2231.10671973
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.21 - /usr/local/opt/openjdk@11/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.17 => 0.71.17
    react-native-macos: Not Found

"@notifee/react-native": "7.8.0",

and

"@react-native-firebase/analytics": "19.2.2",
"@react-native-firebase/app": "19.2.2",
"@react-native-firebase/messaging": "19.2.2",
(also tried 18.8.0, 18.9.0)

2

Answers


  1. Having tried many options to fix the above. Especially, when encountering issues with sending push notifications via Firebase to iOS devices.

    First thing you might need to troubleshoot is to ensure that your Firebase project settings are correct, particularly the APNs authentication key or certificate for iOS push notifications.

    Regarding your payload, it looks mostly correct, but there are a few points to clarify:

    • Make sure that the content_available field is set to true (without
      quotes) rather than ‘true’.
    • The priority field should be set to high for notifications that
      should be delivered immediately. However, since you’re using
      data-only notifications, the priority may not be affecting your case
      directly. Still, it’s good practice to set it correctly.
    • In your payload, you’re using the data field for sending custom data
      to the app. This should work fine, but remember that on iOS,
      data-only notifications may not display anything to the user if the app is in the background or terminated. You’ll need to
      handle the incoming data and decide how to display it within your
      app.

    Given your setup, here’s a revised payload example:

    {
      "message": {
        "token": "some token",
        "data": {
          "title": "some title",
          "body": "some body",
          "content_available": true,
          "priority": "high"
        }
      }
    }
    

    If you’re still facing issues after ensuring the above points, you will need to look deeper into the specifics of your iOS setup:

    • Are you correctly handling incoming notifications in your iOS app?
    • Ensure that you’ve implemented the necessary methods in your app delegate to process incoming notifications when the app is in the foreground, background, or terminated.
    • Verify that your Firebase iOS SDK setup is correct, including the initialization code and any necessary configurations in your Info.plist.
    • Check if there are any error logs or warnings in the Xcode console when receiving notifications.
      If you covered all these aspects and the issue persists, it might be beneficial to provide more details about how you’re handling notifications in your iOS app and any error messages you’re encountering. This will help in diagnosing the problem more accurately.
    Login or Signup to reply.
  2. The behaviour you are describing for iOS is expected.

    If a device is offline, APNS may coalesce messages for an app and only deliver the most recent:

    • If APNs doesn’t deliver a notification immediately, either for device power considerations or because the destination is offline, it may coalesce notifications for the same bundle ID.

    Push notifications on iOS do not provide guaranteed delivery. They should not be considered as an alternative to your app fetching data from a server. A silent push notification can be used as a trigger to tell your app to fetch data from the server.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search