[Huawei Developers] Freemind R:
Cocos Creator has supported HMS Core and HUAWEI AppGallery Connect, through which you can quickly release your games with one click, reducing such complex operations as the SDK integration and app upload during development. In this way, you can build high-quality and innovative apps to improve game experience.

Based on this guide, you can learn how to send messages by Push Kit in Cocos step by step.

Procedure Overview

1. Create a game on the Cocos website, and create the game project in Cocos Creator.

2. Create an app and configure the app information in AppGallery Connect, configure Cocos SDKHub and the building flow, and add the HUAWEI_HMS (Push) plugin and select HUAWEI AppGallery Connect from SDKHub Configuration.

3. Perform coding to obtain a token and build an APK.

4. Test the function of sending notification messages and data messages.

Procedure Details

Step 1: Create a game on the Cocos website, and create the game project in Cocos Creator.

1. Visit https://passport.cocos.com/auth/signup, and sign in with a Cocos developer account. (If you have no account, register one.) Then create a game.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095514.38422276239979082812629864275373:50511026081743:2800:A4829B7D168792DE628A34A8B2882E52BF702579802A2C5E9316AA836FBA65A8.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095514.38422276239979082812629864275373:50511026081743:2800:A4829B7D168792DE628A34A8B2882E52BF702579802A2C5E9316AA836FBA65A8.png[/IMG]

2. Visit http://www.cocos2d-x.org/products#creator, and download and install Cocos Creator.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095540.48153334021044772234127675063137:50511026081743:2800:014DFA4AB8FCC7ACA49FE5E75F6181CB8A6E404C73A6DB3B57F7C60119ADDD8B.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095540.48153334021044772234127675063137:50511026081743:2800:014DFA4AB8FCC7ACA49FE5E75F6181CB8A6E404C73A6DB3B57F7C60119ADDD8B.png[/IMG]

3. Start Cocos Creator, choose Project, and click New. In the window that is displayed, configure project information, and click Save. The project creation is completed.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095606.54792907401086337763280818472316:50511026081743:2800:290C9D48631276F7A9777D8A768746D433EC1A1D86D76B360CC24890A2A103AC.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095606.54792907401086337763280818472316:50511026081743:2800:290C9D48631276F7A9777D8A768746D433EC1A1D86D76B360CC24890A2A103AC.png[/IMG]

If the following error occurs during creation, download Editor.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095623.06651944829486661775155450157671:50511026084402:2800:1308FF0EDA87B7382FE533F6481D11BFAF3756924C878F63BCF7E053DDAA7F3F.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095623.06651944829486661775155450157671:50511026084402:2800:1308FF0EDA87B7382FE533F6481D11BFAF3756924C878F63BCF7E053DDAA7F3F.png[/IMG]

In Cocos Creator, choose Editor, select version 2.4.2 on the right, and click Download.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095638.01883562664595907909996877294458:50511026081743:2800:F85584290FAEFB7640829356C7EDA4792ECDA4C62EBCF9C7DB1B469E753C25F8.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095638.01883562664595907909996877294458:50511026081743:2800:F85584290FAEFB7640829356C7EDA4792ECDA4C62EBCF9C7DB1B469E753C25F8.png[/IMG]

Step 2: Create an app and configure the app information in AppGallery Connect, configure Cocos SDKHub and the building flow, and add the HUAWEI_HMS (Push) plugin and select HUAWEI AppGallery Connect from SDKHub Configuration.

1. Create an app and configure the app information in AppGallery Connect by referring to the guide in https://developer.huawei.com/consum...re-Guides/android-config-agc-0000001050170137.

The key steps include:

Generating a signing certificate fingerprint

Configuring the signing certificate fingerprint

Setting a data storage location

Enabling required services

Downloading the agconnect-services.json file

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095752.59028005300255111258727796078188:50511026081743:2800:B2B1938A4CD70746528AA2B3C30612DE7E9839D78B74606E131811B7D9481184.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095752.59028005300255111258727796078188:50511026081743:2800:B2B1938A4CD70746528AA2B3C30612DE7E9839D78B74606E131811B7D9481184.png[/IMG]

After the app information configuration, perform configuration in Cocos Creator.

2. Choose Panel > Service.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095903.24429108694420729759010614962931:50511026081743:2800:C690F1C362B127322DFC90EA5EE1F93CCDC630AE5B42706F0DD87D53305FFD5B.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095903.24429108694420729759010614962931:50511026081743:2800:C690F1C362B127322DFC90EA5EE1F93CCDC630AE5B42706F0DD87D53305FFD5B.png[/IMG]

3. Select your project.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095928.22897569604943590887766875972426:50511026081743:2800:B198041D6C488A39AB9A22C688D9826A7C2300D506965D09A610ADA26315E2B6.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095928.22897569604943590887766875972426:50511026081743:2800:B198041D6C488A39AB9A22C688D9826A7C2300D506965D09A610ADA26315E2B6.png[/IMG]

Select Cocos SDKHub on the page that is displayed.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095954.44303038221863507894001085509923:50511026081743:2800:1D7C007AE6A849163CDBCF2F9654709E211E40E4E9874E08BF7C1E29801A1F14.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930095954.44303038221863507894001085509923:50511026081743:2800:1D7C007AE6A849163CDBCF2F9654709E211E40E4E9874E08BF7C1E29801A1F14.png[/IMG]

4. Click Plugin Manage.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930100022.95911783046982230971323513143821:50511026081743:2800:EF9CECD5E33378C9AB832AB7D22ADDF5D3670377D847999C65A9BAFE7DE2A01F.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930100022.95911783046982230971323513143821:50511026081743:2800:EF9CECD5E33378C9AB832AB7D22ADDF5D3670377D847999C65A9BAFE7DE2A01F.png[/IMG]

5. Select Push and click OK. The page shown in the preceding figure is displayed.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930100046.08598134364637695409530110725794:50511026081743:2800:65D7D1D4894B177C436CA0B2307F0A48E2761974C1034378FFD11BC22EB99C35.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20200930100046.08598134364637695409530110725794:50511026081743:2800:65D7D1D4894B177C436CA0B2307F0A48E2761974C1034378FFD11BC22EB99C35.png[/IMG]

6. Move the cursor to Not Configured in Params. The editing icon is displayed. Click it.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063701.66039650700768522095746335558915:50511026081743:2800:73F9D3EF164BD977B86574134CD06761D24BF06799E922C3F4147A0E346CBE5C.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063701.66039650700768522095746335558915:50511026081743:2800:73F9D3EF164BD977B86574134CD06761D24BF06799E922C3F4147A0E346CBE5C.png[/IMG]

7. Select a required JSON file, and click OK.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063732.05992252329426116401405882786233:50511026081743:2800:235B883988C945B506C0C9850F1D8A84ADB8448470A5CD47375702C4D77C01F9.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063732.05992252329426116401405882786233:50511026081743:2800:235B883988C945B506C0C9850F1D8A84ADB8448470A5CD47375702C4D77C01F9.png[/IMG]

8. Choose Project > Build.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063801.40800977943968681157617524696364:50511026081743:2800:944EE3F67342761E17ECA3F6BE0390BBA873EC81E7830CB6E75B92B2CF60523A.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063801.40800977943968681157617524696364:50511026081743:2800:944EE3F67342761E17ECA3F6BE0390BBA873EC81E7830CB6E75B92B2CF60523A.png[/IMG]

The Build panel is displayed on the right.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063921.21708307445921224096235535065763:50511026081743:2800:8EF5AF1D405EF5F5752585B6AE7841E7F3FFD572030AF5DE86765D319059DA19.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063921.21708307445921224096235535065763:50511026081743:2800:8EF5AF1D405EF5F5752585B6AE7841E7F3FFD572030AF5DE86765D319059DA19.png[/IMG]

9. Set SDKHub Configuration to HUAWEI AppGallery Connect, and click Build.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063953.17086908864428776742963219245826:50511026081743:2800:43850845257922C6DEBAA50EE455232575E6C505ACB6A467C43DA7095C0A7C71.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009063953.17086908864428776742963219245826:50511026081743:2800:43850845257922C6DEBAA50EE455232575E6C505ACB6A467C43DA7095C0A7C71.png[/IMG]

If the following error occurs during building, install NDK.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064023.46775493954255613377456333613827:50511026081743:2800:A968896C14D1E4F30F5C8B33B8C6FF6C856B0D7F6D3018929D45FED5D47B79EA.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064023.46775493954255613377456333613827:50511026081743:2800:A968896C14D1E4F30F5C8B33B8C6FF6C856B0D7F6D3018929D45FED5D47B79EA.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064043.45153053830163172342693800629986:50511026081743:2800:1AD1534AE604722563F32CF94C1EBA9B11EF7E905EBAC1919281A88286275236.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064043.45153053830163172342693800629986:50511026081743:2800:1AD1534AE604722563F32CF94C1EBA9B11EF7E905EBAC1919281A88286275236.png[/IMG]

After the installation, click Compile. The progress status becomes completed.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064113.00163802817482520724341315345742:50511026081743:2800:1196B3BF5978A514DD7179E23C10F6123D3B157DD9D55DB2CB35EEACC542D46F.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064113.00163802817482520724341315345742:50511026081743:2800:1196B3BF5978A514DD7179E23C10F6123D3B157DD9D55DB2CB35EEACC542D46F.png[/IMG]

Step 3: Perform coding to obtain a token and build an APK.

The following figure shows the project structure.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064155.27049535835403768062712219246742:50511026081743:2800:AC61AE22759AA403D6BF6FDC79346EA4282B0A5818B9936DAE18C94CD3B7C1FB.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064155.27049535835403768062712219246742:50511026081743:2800:AC61AE22759AA403D6BF6FDC79346EA4282B0A5818B9936DAE18C94CD3B7C1FB.png[/IMG]

In Cocos Creator, select js-sdkhub.js file from Assets at the lower left corner.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064219.92898318546615765443508976516375:50511026081743:2800:8342443F4A4DFC29F9E51E14CEAB61E6E7A8CFBA80146AEF948154282888CF8A.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201009064219.92898318546615765443508976516375:50511026081743:2800:8342443F4A4DFC29F9E51E14CEAB61E6E7A8CFBA80146AEF948154282888CF8A.png[/IMG]

More information, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201368424613350372&fid=0101187876626530001