The documents pushed by Huawei are rubbish rubbish rubbish!

Huawei mobile phones are added to the process group mechanism, and the process is also killed after the application is killed in the background. This has a great impact on the development of push and resident processes. In order to solve this problem, Huawei push is used, and the Huawei push process is resident, so We can guarantee the delivery rate of the push and do something small: keep the process alive.

Please don't read that junk document when accessing Huawei Push. If you have any questions, please refer to the related blog of the short book!

Directly record two important pits

The onEvent function needs to be called back, and the server must add the customize field

② Every click on the notification bar will open the application startup page. Here you need to customize an action. You can't read official documents, garbage garbage garbage!

How to customize the action? First, add a transparent activity to the Manifest, and add the following intent-filter (define a transparent activity by yourself, the specific processing logic is in the code)

<intent-filter>
         <action android:name="android.intent.action.VIEW" />
         <category android:name="android.intent.category.DEFAULT" />
         <data
             android:host="idea.analyzesystem.huaweisb(可配置为自己项目的包名)"
             android:path="/notification(/+这里随便写英文)"
             android:scheme="huaweisbpush(这里随便写英文)" />
     </intent-filter>

The string of the custom action can be handed over to the server through code printing processing, the following is my example code block

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("huaweisbpush://idea.analyzesystem.huaweisb/notification?message=what"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String intentUri = intent.toUri(Intent.URI_INTENT_SCHEME);

An application needs to access N kinds of push solutions corresponding to the respective mobile phone brands. I just want to say that Huawei push documents are rubbish, rubbish, rubbish. I think what I said is very reasonable, you can give me a recognition and a like! !

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324538758&siteId=291194637