preface

Users reported that they were able to receive notifications when they were using the app, but were unable to receive them when the app was closed. The problem was ☺ notifications when the app was opened. It has to be pushed to each manufacturer channel, the project used the Friendship alliance push, the advantage is that you do not have to look at the manufacturer push document, as long as the manufacturer push to obtain the value to the line, other to the friendship alliance on the line, although it seems to be very simple, but also step on a lot of pits, in this record.

This article will not be integrated from the beginning, look at the official documentation, step by step, soon to be integrated.

Their Allies push website address: developer.umeng.com/docs/67966/…

First test the message through the Umeng web page

This running is no problem, and then with background debugging, you can save a lot of time.

The test message is shown below:If no test device is available, click on the upper right corner to add a device firstCreating a Test DeviceAnd fill in the obtained deviceToken. DeviceToken is obtained from the following figure:Then you can test the message by selecting the deviceToken user

I thought I would soon be able to receive a notification of the result, but I did not receive it, embarrassed, then I will look at the reason, first look at the AS log there is no error, sure enough, I found a section of the log reported red…

Mobile Terminal Troubleshooting

  1. Huawei logs report an error. Procedure

Huawei logs are recorded in red. You can see that the API exception is reported in the logs, and the error code is 6003

At this time, we need to go to huawei push official website to check the corresponding information of the error code. The common error code address is:Developer.huawei.com/consumer/cn…

Are the fingerprints of SHA256 certificates inconsistent? “, and then get SHA256 again, found the last letter is not the same, and then replace with the latest obtained, it takes about a minute to take effect. Open the APP again and find that the token has been obtained successfully.To obtain SHA256, run the command line interface (CLI) to go to the bin directory of the JDK and enter keytool -list -v -keystore 2. Huawei’s return receipt switch is not on, and the service is not on

After the SDK is integrated with huawei channels, you need to configure message receipt on the Huawei background to obtain data such as the number of received messages sent through Huawei channels. The following two must be opened, I forgot to open. Specific see friends union official document, huawei, set the message receipt: developer.umeng.com/docs/67966/…

Huawei push service address:Developer.huawei.com/consumer/cn… Huawei AppGallery Connect API service address:Developer.huawei.com/consumer/cn…

  1. Print the log to see the message push coming, but does not show in the notification bar (if the notification bar is also enabled)

Then I tested the push in the Web version of UmENG, and found that the pushed message could be seen in the AS log, but it was not displayed in the notification bar. Nani?

After the investigation, it was found that the alliance related package was encapsulated into a lib package, because the following files need to be added during the integration of alliance.

However, when umeng searches for resources, the default search is from the main package name, so it cannot find this resource, the liberation method is: set resource package name method

PushAgent.getInstance(application).resourcePackageName = "Package name for resource"
Copy the code

Notification bar message received after setting (offline state oh, after App killed)

After the self-test, it was formal and background debugging, embarrassed, the background pushed a message, did not receive, careful colleagues (thumbs up) found that the API document did not include these two fields, suspected that the background did not add, because when sending messages through the Web page of UmENG, there are these two fields in the JSON string every time, as shown below:

The back-end screening

1 ** Call buddy API, send message without mi_activity, mipush field or call channel_activity”

So he asked for the work order, and the man said:

Hello, please refer to the document developer.umeng.com/docs/67966/… . The latest method calls channel_activity. This parameter is optional if mipush and mi_activity are used instead of miPUSH and mi_activity

Big hole!! After that, I still can’t get it offline.

2 problem caused by field display_type

The background colleague found that when calling the API, display_type sent “message”, so it changed to “notification” and was successfully pushed.

Pay attention toWhen changed to “notification”, the body of the message returned is also different. Remember to change this.

After the summary processing, it seems that the problem is not difficult, it seems that it is not so, haha. The power of an individual is limited, the power of a team is infinite.