Edit 11/24/2016:
I just got the word from Firebase Support. They think this is Asus problem. The device I'm using is Asus ZenFone 2 Laser. Here is their answer:
The problem here is that Google does not control how manufacturers configure their version of Android. If Asus follows the Android manual, then the notification should work (for example, on the other side of the device).
One thing we discovered is that some phones put applications in a power stop which prevents the application from receiving a notification.
From your test result, this does not seem to be the case. BUT there are many other ways in which Asus can stop notifications from working, and unfortunately, we cannot check all of them.
You would be better off contacting Asus and letting us know if there is any news.
Since this is a low priority issue for my client, I am not going to continue it further at this time. Unfortunately, I do not have time to test the same problem on other devices. If this changes in the future, I will update this problem. Until now, I will consider this unresolved. I would be interested to hear if others have the same problems on other brand phones.
As for Asus users, you should consider: there are energy-saving options that turn off notificaitons.
30/09/2016:
Firebase . , , , :
, , , . adb shell dumpsys package | grep stopped :
User 0: installed=true hidden=false stopped=false notLaunched=false enabled=0
, ( Firebase). .
27/09/2016:
notification data. . , , . , , ( ), .
, .
FCM . ( FCM.) - notification, data. , onMessageReceived(). (.. "" ), onMessageReceived() ( ), . MyFirebaseMessagingService.onCreate() onDestroy(), .
, , " " , . onCreate() onDestroy() . . , .
:
{
"to":"token",
"priority":"high",
"notification": {
"body":"hello",
"title":"Message from Mom",
"click_action":"ACTIVITY_MAIN"
},
"data":{
"open":"chat"
}
}
FCM:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onCreate() {
super.onCreate();
Log.v(DmcApplication.TAG, "Service Created");
}
@Override
public void onDestroy() {
super.onDestroy();
Log.v(DmcApplication.TAG, "Service Destroyed...");
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.v(DmcApplication.TAG, "Message received!");
EventBus.getDefault().post(new MessageEvent(remoteMessage.getNotification().getBody()));
}
}
( )
<service
android:name="com.example.package.myFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Logs:
//Log when app is in foreground and message comes in:
V/coo: Service Created
V/coo: Message received!
V/coo: Service Destroyed...
//Log when app is in background and message comes in:
V/coo: Service Created
V/coo: Service Destroyed...
//Log when app is killed:
<silence...>
, .