Reasons why Android FCM push cannot be received

I’m afraid I won’t be able to find the article in the future, so I’ll make a backup copy here.

First, let’s talk about what kind of mobile phones and status can receive FCM push, and which channel different data formats will take.

Format 1 

{
    "to": "cvRJ6BXFTQiyB9W5pqcx-E:APA91bE",
    "notification": {
        "title":       "Pickup Offer!",
        "body":        "Address detail",
        "click_action": "yourapp://pickup"
    }
 
}


Format 2 

{  
   "to":"dk_FO2LEdlI:APA0",
   "data":{  
             "title":"Pickup Offer!",
            "body":"Address detail",
            "click_action":"yourapp://pickup",
            "event":"PICKUP",
            "address":"Address detail"
   }
}


Format three 

{  
   "to":"dk_FO2LEdlI:APA0",
   "notification": {
        "title":       "Pickup Offer!",
        "body":        "Address detail",
        "click_action": "yourapp://pickup"
   },
   "data":{  
             "title":"Pickup Offer!",
            "body":"Address detail",
            "click_action":"yourapp://pickup",
            "event":"PICKUP",
            "address":"Address detail"
   }
}

1. Foreign native systems:

No matter what state the phone and the application are in, there is a high probability that the push will be received. Because the Google service is original and starts with the system, the Google Service can run in the background for a long time, and after receiving the message, it will evoke the broadcast or service registered by the application, thus Evoke application.

However, different push formats will go through different channels. When the application is running, it will 100% go through

FirebaseMessagingService

However, after the application is killed, if a push in format 1 is received, the system will bypass your application and directly create the push, and use click_action to implement click jump.

And if you receive a push in format 2 or 3, the method you rewrote by extending MyFirebaseMessagingService will be used.

<service
    android:name=".java.MyFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>


2. Domestic customization system:

In a circumvention environment and when the application is running, there is a high probability that push notifications will be received. However, after the application is killed, some mobile phone versions may receive push notifications in Format 1.

Push formats 2 and 3 cannot be delivered because the FCM service has been killed.

3. Push rate

The above-mentioned push notifications are all highly likely to be received, but don’t beat your chest and assure the PM that there will be absolutely no problem, because there are many other factors that lead to the inability to receive them. Let’s list them:

1 The network is congested, or the FCM server is congested. The message sent in the morning did not arrive until the evening.

2 When the application is killed, it cannot receive messages because the broadcast or service cannot be started. When the application is opened, offline messages will be pushed crazily. This is because of the caching mechanism. The default cache is 4 weeks. The evidence is here .

3 The priority is too low and the user will not be disturbed. Here is the evidence.

4 Power management causes, the evidence is here, Android official , Samsung official , PushWoosh

Summary:
Whether you can receive push notifications all depends on your network conditions and whether the FCM service has been killed or disabled. If it has been killed, it also depends on whether the system will process push notifications in format one.

Some mobile phones are really weird. Even some foreign versions of Samsung will no longer wake up the push broadcasts or services registered by the App after killing the App.


Original link

Guess you like

Origin blog.csdn.net/qq_40150532/article/details/131770278