Quickstart-unity: Don't receive fcm notification when I exit the unity app,only user open the unity app the mobile notifiction list can show the fcm push notification.

Created on 12 Dec 2016  ·  14Comments  ·  Source: firebase/quickstart-unity

Use the Unity plugins of Messaging on Android.Can't receive push notification on the mobile notifiction list when exit the unity app.

bug

Most helpful comment

Hi, I have the same issue. I sent three types of notifications (User segment, Topic and Unique Device)

The app gets the notification when app is running in the foreground in callbackFunction; when app resident in the background as notification on system tray but cannnot get notification when
App is not running or killed.

I need urgent support.

All 14 comments

It sounds like the Firebase Messaging service isn't launched in the application. If you're customizing the AndroidManifest.xml for your application you'll need to make sure you follow the setup instructions on https://firebase.google.com/docs/cloud-messaging/unity/client#note_for_android

@stewartmiles I use quickstart samples to test.It also not receive push notification on the notificition list when i exit the sample application.Can receive push notification only when the application is on runtime.

@stewartmiles I means that the fcm service (about the current unity application) isn't always Resident background when user exit app.

We just tested this again and we are definitely seeing notifications come in when sending to the application when:

  • App is running in the foreground
  • App is running / resident in the background
  • App is not running

To be clear when the app is in the background or not running you don't get a callback when the notification comes in. The app gets to service the notification when it reopens due to a user clicking on the notification. Is this the behavior you're seeing?

@stewartmiles I see the behavior is that When App is not running the notification don't comes in.
When App is running in the foreground or App is running / resident in the background my app works fine.

How are you sending the notification?

Are you using the notification console?
https://firebase.google.com/docs/notifications/android/console-audience#send_a_message_from_the_notifications_console

I just built the sample + the 1.1.0 SDK and verified the following on a Nexus 4 running Android 4.3 (because I like to keep it old skool 👍 ):

  • Sending message to the game while it's open, receives the message displays in the log window
  • Sending message to the game while it's in the background, notification in the notification tray
  • Closed game (swipe away), send message to the topic - notification displayed in the notification tray.

I've attached a screenshot of the message I sent via the notification console.

notification

@stewartmiles Thank you first of all.
I found that:
A: run app on HUAWEI P8. The notification don't comes in.This HUAWEI P8 is made for chinese,the reason may be about this custom system

B: run app on SUMSUNG Galaxy S4.The notification comes in via Topic notification console.But the notification don't comes in via User segment(using the Bundle identifier) notification console.This is also a issue.Do you see this behavior?
The follow is my init code:
//FCM's init
public void InitializeFirebase()
{
Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
Firebase.Messaging.FirebaseMessaging.Subscribe ("TestTopic");
}

Hi, I have the same issue. I sent three types of notifications (User segment, Topic and Unique Device)

The app gets the notification when app is running in the foreground in callbackFunction; when app resident in the background as notification on system tray but cannnot get notification when
App is not running or killed.

I need urgent support.

@MustafaKilci Sorry,i don't fix this.Just wait the other one or the next release.

Hi, I have the same issue

The details of the expected behavior are here
https://firebase.google.com/docs/cloud-messaging/android/receive:

  • When the app is running in the foreground the notification is routed
    from the service (that handles the notification) to the SDK which then
    fires the callback.
  • When the app is in the background and running we can route the
    notification to the app, as it's running :)
  • When the app isn't running / killed, our service runs which receives
    the notification and caches it. When the user clicks on the notification
    the notification is routed to the app when it's launched.

If you want to customize what happens in the notification when the app
isn't running you'll need to subclass our service
(com.google.firebase.messaging.cpp.ListenerService which implements
FirebaseMessagingServices
https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService)
and replace the reference to it in your Android manifest. You can then
override the onMessageReceived() method to customize the behavior in your
service. Obviously, this is not particularly cross platform as there is no
way to do this on iOS.

Cheers,
Stewart

On Fri, Jan 13, 2017 at 1:47 PM, phpnato notifications@github.com wrote:

Hi, I have the same issue


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/quickstart-unity/issues/25#issuecomment-272556807,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFw1RFlIAFJEBn7U478e6MkY9xP_nMThks5rR_D7gaJpZM4LKSDG
.

Closing out as it sounds like we need to clarify our docs on this behavior.

any updates on this? anyone customised the implementation to get it work when app is killed.

@nabeelpkl if you want to customize messaging handling on Android when the app is in the background (i.e just the messaging service is running) see https://firebase.google.com/docs/cloud-messaging/cpp/client#custom_message_handling_on_android (the Unity SDK uses the C++ SDK under the hood).

Was this page helpful?
0 / 5 - 0 ratings