Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Firebase Notifications: iOS gets "data" but not "notification"

Discussion in 'Formats & External Tools' started by Antistone, May 15, 2019.

  1. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    I am using Firebase to send notifications for a Unity game. On iOS, my test devices are receiving the "data" field of the notification (with parameters unique to my game) but not the "notification" field (title+body text for the user).

    On Android, notifications work as expected:
    • If the app is in the foreground, it receives both "notification" and "data" fields.
    • If the app is in the background, the OS displays an alert with the "notification" params. When I tap the alert, the app opens and receives the "data" params (only).
    On iOS:
    • If the app is in the foreground, it receives "data" params only.
    • If the app is in the background when the notification arrives, nothing happens immediately. The next time the app regains focus, it receives the "data" params only.
    • The OS does not display an alert in any test case.
    • The app does not receive the "notification" params in any test case.
    I have tested on two different iOS devices (one iPhone running iOS 12.2, one iPad running iOS 11.1).

    I have also tried sending text-only notifications using the Firebase Notification Composer. These notifications arrive on my Android test device, but have no apparent effect when sent to iOS.

    I configured my Unity game and Firebase project following the instructions here: https://firebase.google.com/docs/cloud-messaging/unity/client

    Probably not relevant (since the notification composer is also affected), but for sending out notifications I am using this library on my server: https://github.com/Redth/PushSharp/

    Any thoughts on what could be going wrong?
     
    Playa_rc likes this.
  2. Playa_rc

    Playa_rc

    Joined:
    Dec 10, 2013
    Posts:
    7
    Hello. Have you found any solution?
     
  3. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    I eventually discovered that alerts would be displayed by the OS as expected if we downloaded the build through Test Flight, but did not work when placed directly on the test device from our development machine.

    Also, even via Test Flight, the behavior seems to be different between iOS and Android: on Android, the "notification" portion is visible to the app if the app is foregrounded when the notification is received, but not if it was backgrounded. On iOS, that data is available in both cases--which is arguably a feature, except now I'm not sure how to tell whether the app was in the foreground or the background when the notification is received, which is inconvenient if I want to trigger different behavior in those cases.
     
    xaldin-76 and Playa_rc like this.
  4. shubham0290gupta

    shubham0290gupta

    Joined:
    Nov 4, 2018
    Posts:
    1
  5. sindhumca48

    sindhumca48

    Joined:
    Mar 27, 2022
    Posts:
    1
    is the issue resolved?