Message push
Unity3D
Outline
Access Guide
TPNS push
Send push message
Add local push
Tag push
Vendor Channel Push
FAQ
Android
Outline
Access Guide
TPNS push
Send push message
Add local push
Tag push
Vendor Channel Push
FAQ
IOS
Outline
Access Guide
TPNS push
Send push message
Add local push
Tag push
FAQ
Others
Data Structure
System Tools
Message push / Unity3D / Outline

Outline

The push function can push game-related information to the player's phone in case that the game is not running, such as a variety of holiday activities, anniversary activities. The push effect is shown in the following diagram:

Access Guide

1 Preconditions

1)You have follow MSDK unity Access Configuration module's explanation to complete Access Configuration, and ensure the push switchPUSHhas been checked.

2)MSDK iOS push is realized through Apple Push Notification Service(APNS). The PM of every business or Tencent contact person need to configure relevant certificatesConfigure relevant certificates in Tencent’s internal networkRDM or The Flying Eagle System.

2 iOS configuration certificate

Configuration certificates are only tailored to iOS terminal and can be neglected at the Android terminal.

1 Apply for a certificate

2 Make SSL Certificate

3 Upload SSL Certificate

1 Apply for a certificate

Products need to apply for push and release certificates at RDM(Tencent’s internal network; applied for by business PM or Tencent contact person). For details, consult RDM Helper via RTX.

2 Make SSL Certificate

1)Download P12 certificate from RDM(Tencent’s internal network; applied for by business PM or Tencent contact person). The specific path is: Game product ->Release management -> Certificate management. Take MSDK as an example, as shown in the figure below:

2)Download xxx_push.p12 file under the release certificate from the opened UI
3)Open the terminal and enter the directory where xxx_push.p12 file is located to execute the following command:
openssl pkcs12 -in xxx_push.p12 -out xxx_push.pem -nodes

3 Upload SSL Certificate

1)Enter the Flying Eagle system(Tencent's internal network; operated by business PM or Tencent contact person), click the left navigation bar's Game management ->All games (contact marsrabelma Ma Teng through RTX to get the permissions if you have no permissions), and query your own game. Here, take MSDK as an example, as shown in the figure below:

2) Click Check button in the figure above to enter the game's details page to find the information in the figure below:

3) Click Compile IOS information button in the figure above to access iOS information page, as shown in the figure below:

Upload pem certificate generated in Step 2 Make SSL certificate to the production environment. There is no need to fill the password. After uploading it successfully, click the Update game IOS info button at the top left corner to save it. Just ignore the development environment certificate. At this moment, the certificate has been configured.

iOS add push related code

Choose OC interface or C++ interface to use

1 the following interface is OC interface

You still need to add five methods in relation to push in AppDelegate.mm:

1) Register push

Only when the signature file is correctly configured can push be successfully registered. In didFinishLaunchingWithOptions method, call MSDK’s WGRegisterAPNSPushNotification method to register push. The demo code is as follows:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    …
    [MSDKXG WGRegisterAPNSPushNotification:launchOptions];
    …
}

2) Registration succeeds

After the registration succeeds, the game will receive didRegisterForRemoteNotificationsWithDeviceToken callback method. The game needs to call WGSuccessedRegisterdAPNSWithToken method in the method to report deviceToken to MSDK. Demo code:

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [MSDKXG WGSuccessedRegisterdAPNSWithToken:deviceToken];
}

3) Registration fails

After the registration fails, the game will receive didFailToRegisterForRemoteNotificationsWithError method callback. At this time, the game needs to call WGFailedRegisteredAPNS method to inform MSDK of the failed push registration. Demo code:

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  [MSDKXG WGFailedRegisteredAPNS];
}

4) Receive messages

After push is successfully registered, app will receive the push message and then enter didReceiveRemoteNotification method. After that, the game needs to call WGReceivedMSGFromAPNSWithDict method in the method to push the message to MSDK to parse it. The parsing result will be notified to the game. Demo code:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
  [MSDKXG WGReceivedMSGFromAPNSWithDict:userInfo];
}

5) Clear badge

App needs to clear the push item at the top right corner of the desktop icon of the app through calling WGCleanBadgeNumber method in applicationDidBecomeActive. Demo code:

-(void)applicationDidBecomeActive:(UIApplication *)application
{
  [MSDKXG WGCleanBadgeNumber];
}

2 the following interface is C++ interface

You still need to add five methods in relation to push in AppDelegate.mm:

1) Register push

  • Functional description

Registration message push,Only when the signature file is correctly configured can push be successfully registered. In didFinishLaunchingWithOptions method, call MSDK’s WGRegisterAPNSPushNotification method to register push.

  • Interface declaration
void WGRegisterAPNSPushNotification(unsigned char *launchOptions);
  • Parameter Description
Parameter Name Type Description
launchOptions unsigned char* (NSDictionary *)launchOptions parameter in "-application:didFinishLaunchingWithOptions:" is converted to json string

2) Registration succeeds

  • Functional description

After the registration succeeds, the game will receive didRegisterForRemoteNotificationsWithDeviceToken callback method. The game needs to call WGSuccessedRegisterdAPNSWithToken method in the method to report deviceToken to MSDK.

  • Interface declaration
void WGSuccessedRegisterdAPNSWithToken(unsigned char *deviceToken);
  • Parameter Description
Parameter Name Type Description
deviceToken unsigned char* (NSData *)deviceToken parameter in "-application:didRegisterForRemoteNotificationsWithDeviceToken:" is converted to a string

3) Registration fails

  • Functional description

After the registration fails, the game will receive didFailToRegisterForRemoteNotificationsWithError method callback. At this time, the game needs to call WGFailedRegisteredAPNS method to inform MSDK of the failed push registration.

  • Interface declaration
void WGFailedRegisteredAPNS();
  • Parameter Description

None

4) Receive messages

  • Functional description

After push is successfully registered, app will receive the push message and then enter didReceiveRemoteNotification method. After that, the game needs to call WGReceivedMSGFromAPNSWithDict method in the method to push the message to MSDK to parse it. The parsing result will be notified to the game.

  • Interface declaratio
void WGReceivedMSGFromAPNS(unsigned char *userInfo);
  • Parameter Description
Parameter Name Type Description
userInfo unsigned char* (NSDictionary *)userInfo parameter in "-application:didReceiveRemoteNotification:" is converted to json string

5) Clear badge

  • Functional description

App needs to clear the push item at the top right corner of the desktop icon of the app through calling WGCleanBadgeNumber method in applicationDidBecomeActive.

  • Interface declaratio
void WGCleanBadgeNumber();
  • Parameter Description

None

Tencent Mobile Push TPNS

TPNS is the charged version. If you want to access it, you need to apply for the accessId and accessKey again. MSDKV3 client has started to integrate TPNS since Version 3.3.12. Currently, TPNS supports pluginized access.

Important: To avoid Huawei vendor channel push exceptions, the access party must upgrade the MSDK version to MSDK3.3.16 (TPNS 1.2.0.4) or above before June 30, 2021.

1 Apply accessId and accessKey

accessId and accessKey can be directly applied for at Feiying System (Intranet access). Please contact MSDK Assistant to assist in registration

If the game has already registered a Tencent Cloud account in the Tencent Cloud console and already has a Cloud XG account, it can also be migrated to Feiying System. You need to contact MSDK Assistant to assist in migration

  • To register and apply in the Feiying system or to migrate to the Feiying system, you need to provide UIN (you can log into the Tencent Cloud's official website to view the UIN: https://console.cloud.tencent.com/developer
  • Internal users of the company can use Tencent Cloud's internal account to purchase it. As for the company's internal account query method and application method, please see https://docs.qq.com/doc/DVWZBYkJ2SHBaUE9y

2 Android Client access instructions

Starting from MSDK3.3.18 version, Tencent Mobile Push has been separated into TPNSSDK and HWPushSDK plugins.

  • TPNSSDK: Tencent Mobile Push and vendor channel push (MEIZU, VIVO, OPPO, XIAOMI)
  • HWPushSDK: Huawei vendor channel push

Unity version uses TPNSSDK and HWPushSDK by default. If you don't use them, you can delete TPNSSDK and HWPushSDK plugins and comment out the following code (path: \Assets\Msdk\Editor\Scripts\Deploy\DeployAndroid.cs):

```  / 7) TPNSSDK / DeployTPNSSDK();

/ 8) HWPushSDK / DeployHWPushSDK();

<font color="red">**Note:**</font>

+ Starting from the MSDK3.3.18 version, Huawei channel needs to add the Huawei push configuration file, that is, the agconnect-services.json file, to the project's 'assets' directory. The path to obtain the file is as follows:
Log into [Huawei Open Platform] (https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-integrating-sdk-0000001050040084), then enter [My Project]> Select Project> [Project Settings], and download the latest configuration file agconnect-services.json for the Huawei app.
+ Starting from MSDK3.3.18 version, the configuration in the AndroidManifest.xml of Huawei vendor channel push has changed. For details, please refer to [vendor channel component configuration](config.html#Unity_Init).

Unity 64-bit packaging guidelines have been updated. The address of the guidelines documentation:
\Assets\Msdk\Editor\Librarys\Android3.2\Gradle

#### 2.1 Add permissions and component and app information configuration to AndroidManifest.xml
For details, please refer to [Tencent Cloud Version Client Configuration](config.html#Unity_Init) (Search: Required permissions for TPNS, Component configuration for TPNS)

<font color="red">**If the access point is the Shanghai cluster, the following configuration needs to be processed**</font>

Add the following nodes in AndroidManifest.xml

<!-- For TPNS 1.1.6.3 and previous versions including XG_GUID_SERVER, XG_STAT_SERVER and XG_LOG_SERVER, the configuration takes effect; for versions later than 1.1.6.3, such as XG_SERVER_SUFFIX, the configuration also takes effect. It is recommended to add the configuration to prevent incompatibility issues in subsequent upgrades -->

    <meta-data
        android:name="XG_GUID_SERVER"
        android:value="https://guid.tpns.sh.tencent.com/guid/api/GetGuidAndMqttServer" />
    <meta-data
        android:name="XG_STAT_SERVER"
        android:value="https://stat.tpns.sh.tencent.com/log/statistics/push" />
    <meta-data
        android:name="XG_LOG_SERVER"
        android:value="https://log.tpns.sh.tencent.com/v3/mobile/log/upload" />
    <meta-data
        android:name="XG_SERVER_SUFFIX"
        android:value="tpns.sh.tencent.com" />    

+ XG_GUID_SERVER, XG_STAT_SERVER and XG_LOG_SERVER need to carry https header, and XG_SERVER_SUFFIX does not carry https header

#### 2.2 Add accessId and accessKey configuration
 TPNS needs to configure accessId and accessKey. There are two ways to complete the configuration. One way is to configure them in AndroidManifest.xml and the other is to configure them in msdkconfig.ini. The following is a reference example of msdkconfig.ini:

```xml
XG_V2_ACCESS_ID=xxx
XG_V2_ACCESS_KEY=xxx

Note: XG_V2_ACCESS_ID is a string of integer numbers. If this configuration item is set in both AndroidManifest.xml and msdkconfig.ini, the latter shall prevail.

2.3 Log off XG free version

If you do not log off the free version, the same user may receive two identical messages during the upgrade and coverage process of App. The way to log off it is to configure the accessId of the XG free version in AndroidManifest.xml. The configuration example is as follows:

<application>
...
    <meta-data
            android:name="XG_OLD_ACCESS_ID"
            android:value="xxx" />
...
</application>

Among them, old_access_id is filled in with the accessId of the free version XG before the upgrade. If you don't know it, you can query it in Feiying system's SDK parameters section.

2.4 Vendor channel

After TPNS is upgraded, it supports Huawei, Xiaomi, Meizu and OPPO vendor channels. The game needs to apply for the app id, app key, and app secret of each channel by itself (OPPO is involved) and fill in the corresponding results in the TPNS console and client. For specific access guidelines, please refer to Vendor Channel PushMSDK 3.3.255 has begun to remove Huawei, Xiaomi and vivo vendor channel-related capabilities; MSDK 3.3.256 has begun to remove Meizu vendor channel-related capabilities;MSDK version 3.3.28 updates TPNS to version 1.3.7.2 to restore the vendor channel push capability.

2.5 Delete TPNS

If you do not access TPNS, you need to modify and delete the following content, as follows:

  • PUSH is set to false in msdkconfig.ini
  • Delete the TPNS configuration in AndroidManifest.xml and msdkconfig.ini, that is, delete the configuration description in 2.1, 2.2, and 2.3
  • Delete all MSDKLibrary/libs/tpns-*.jar files (starting from version 3.3.18, it is needed to delete TPNSSDK and HWPushSDK plugins at the same level as MSDKLibrary)
  • Please delete vendor channels according to the vendor channel guidelines

3 iOS Client access instructions

The TPNS data reporting capability is the reflection call on the TPNS side, so every game needs to add its own dependency on TPNS. To access TPNS capability, in addition to adding 'MSDKPush/MSDKPush.framework', a game also needs to add the TPNS library and header files in the MSDKPush/XG directory.

3.1 Add configuration in info.plist

TPNS version requires configuring accessId and accessKey information. Please configure iOS TPNS accessId and accessKey in info.plist, where accessId is the Number type and accessKey is the string type. The configuration example is as follows:

    <key>XG_V2_ACCESS_ID</key>
    <integer>xxx</integer>
    <key>XG_V2_ACCESS_KEY</key>
    <string>xxx</string>

If the access point is the Shanghai cluster, the following configuration needs to be processed

In the info.plist file of the project, add XG_HOST https://guid.tpns.sh.tencent.com XG_PORT 0 XG_STAT_HOST https://stat.tpns.sh.tencent.com XG_STAT_PORT 0

<!-- 3.3.16 version's configuration -->
<key>XG_HOST</key>
<string>https://api.tpns.sh.tencent.com</string>
<key>XG_PORT</key>
<integer>0</integer>
<key>XG_STAT_HOST</key>
<string>https://stat.tpns.sh.tencent.com</string>
<key>XG_STAT_PORT</key>
<integer>0</integer>

<!-- 3.3.17 and later versions' configuration -->
<key>XG_HOST</key>
<string>tpns.sh.tencent.com</string>
  • XG_HOST and XG_STAT_HOST need to carry https header
  • 3.3.16 version XG_HOST needs to be modified to https://api.tpns.sh.tencent.com
  • Starting from version 3.3.17, it is needed to delete XG_PORT, XG_STAT_HOST, XG_STAT_PORT configurations, and modify XG_HOST to tpns.sh.tencent.com (Note: no https header is required)

3.2 Log off XG free version

If you do not log off the free version, the same user may receive two identical messages during the upgrade and coverage process of App. The way to log off it is to configure the accessId of the XG free version in info.plist. Please add XG_FREE_ACCESS_ID in info.plist, whose type is Number. The example for the corresponding Key and configuration is as follows:

    <key>XG_FREE_ACCESS_ID</key>
    <integer>xxx</integer>

Among them, XG_FREE_ACCESS_ID is filled in with 'accessId' of the free version of XG before upgrade. If you don't know this, you can query it at Feiying system's SDK parameters section.

3.3 Delete TPNS version

If you do not access TPNS version, you need to modify and delete the following content, as follows:

  • Set MSDK_PUSH_SWITCH to false in info.plist
  • Delete the TPNS configuration in 2.1 and 2.2
  • Delete MSDKPush.framwork

Warning

  • If you want the game to be still able to receive pushes at the front-end, you need to configure MSDK_PUSH_AT_FOREGROUND to true in the info.plist file. The configuration is disabled by default.

4 Console configuration instructions

4.1 Create products and apps

Create products and apps. For details, refer to Tencent Mobile Push - Create Product and Application Documentation

4.2 Apply for trial

Click [Apply for Trial/Test] on the page, fill in "Tencent" for the company name, and enter the phone number and email address according to the information filled in by the applicant. After application, you can contact MSDK Assistant for specific usage methods

4.3 iOS certificate configuration

As for the certificate configuration method, please refer to Tencent Mobile Push - Upload Push Certificate Method Documentation

4.4 Create a push task and a push test method

Create a push task and a push test method. For details, please refer to Tencent Mobile Push-Create Push Task and Push Test Method Documentation

5 TPNS's service payment instructions

TPNS's service payment instructions. For details, please refer to Payment Instructions Documentation

Contact person: Cloud IT support

6 iOS notification service extension configuration (required for the statistics of arrivals)

MSDK only carries the TPNS extension library, which requires game integration access. For specific access, please refer to the TPNS guide document:Instructions for using the notification service extension

Contact person: Cloud IT support

MSDK V3.3.15 and later versions add the following interface

1 Account binding

1) Function description

Developers can bind user-defined accounts for different users, and then push the accounts. The accounts cannot be empty. A single app can have up to 10,000 user-defined tags/accounts, and each device token can be bound to up to 100 user-defined tags/accounts.

  • The account here can be any type of business accounts such as a mailbox, QQ number, mobile phone number, user name, etc.
  • When multiple devices are bound to the same account, the backend will push the message to the last bound device by default
2) Interface declaration

The declaration and related parameter descriptions can be viewed in the WGPlatform.h file

void WGSetPushAccount(unsigned char *account);
3) Parameter description
Parameter name Type Description
account unsigned char * Account
4) Demo code
WGPlatform::GetInstance()->WGSetPushAccount("account");

2 Unbind account

1) Function description

Unbind the bound user-defined account, which cannot be empty.

  • Account unbinding is just to disassociate Token from the App account. If you use the full amount/tag/Token push, you can still receive notifications/messages
2) Interface declaration

The declaration and related parameter descriptions can be viewed in the WGPlatform.h file

void WGDeletePushAccount(unsigned char *account);
3) Parameter description
Parameter name Type Description
account unsigned char * Account
4) Demo code
WGPlatform::GetInstance()->WGDeletePushAccount("account");

3 De-registration

1) Function description

When the user has logged out or App is closed and no longer needs to receive push notifications, you can cancel the registration of the App, that is, de-registration. (Once the device is de-registered, the device will not be able to receive the sent message until the device re-registers successfully).

  • Do not make de-registration too frequently, because this may cause the backend synchronization delay
  • There is no need to de-register in case of account switch. The last registration will automatically prevail in case of multiple registrations
2) Interface declaration

The declaration and related parameter descriptions can be viewed in the WGPlatform.h file

void WGUnregisterPush();
3) Parameter description

None

4) Demo code
WGPlatform::GetInstance()->WGUnregisterPush();

Send push message

Enter the Flying Eagle system(Tencent's internal network; operated by business PM or Tencent contact person), click the left navigation bar's MSDK management->Message management(contact marsrabelma Ma Teng through RTX to get the permissions if you have no permissions), and click Message (formal environment)button in the opened UI. In the formal environment, click +Push notificationbutton to add the push message, as shown in the figure below:

Note:

When testing push messages, do not push their full amount. You can use a single account or batch accounts to test them to avoid the whole network users from receiving the test push message.

Add local push

In addition to remote push, the game can also push local messages, such as physical recovery reminder.

1 iOS local push

2 Android local push

3 Clear local push

1 iOS local push

1)Function description

Local push is message notification which can be completed in the local. Unlike remote push, it doesn't need to interact with the remote server. It is mainly used in physical recovery reminders and other scenes.

2)Interface declaration
long WGAddLocalNotification(LocalMessageIOS localMessage);
3)Parameter description
Parameter name Type Description
localMessage LocalMessageIOS class skip to view it
4)Return value

1 Add successfully, 0 Add unsuccessfully

5)Demo code
//If current time is "2015-09-17 17:00:00", push will commence 10 seconds later
LocalMessageIOS massage = new LocalMessageIOS();
message.fireDate = "2015-09-17 17:00:10";
message.alertBody = "Local Notification";
message.badge = 1;
message.alertAction = "Start";
WGPlatform.Instance.WGAddLocalNotification(massage);
6)Special description

None

7)Term interpretation

None

2 Android local push

1)Function description

Local push is message notification which can be completed in the local. Unlike remote push, it doesn't need to interact with the remote server. It is mainly used in physical recovery reminders and other scenes.

2)Interface declaration
long WGAddLocalNotification(LocalMessageAndroid msg);
3)Parameter description
Parameter name Type Description
msg LocalMessageAndroid class skip to view it
4)Return value

1 Add successfully, 0 Add unsuccessfully

5)Demo code
string[] times = Regex.Split ("20150917 17 00", " ");
LocalMessageAndroid msg = new LocalMessageAndroid();
msg.type = 1;
msg.action_type = 1;
msg.content = "Pigeon local push test";
msg.title = "You have new messages";
msg.date = times[0];
msg.hour = times[1];
msg.min = times[2];
WGPlatform.Instance.WGAddLocalNotification(msg);
6)Special description

None

7)Term interpretation

None

3 Clear local push

1)Function description

The game can clear all local push notifications that have been added but have not yet been executed.

2)Interface declaration
void WGClearLocalNotifications();
3)Parameter description

None

4)Return value

None   

5)Demo code
WGPlatform.Instance.WGClearLocalNotifications();
6)Special description

None

7)Term interpretation

None

Tag push

The game can set tags for the user, such as gender, age, education, hobby, etc.; in addition, some default tags are preset in SDK. When pushing messages, you can push targeted messages based on different tags.

1 preset tag

2 set tag

3 delete tag

4 send the tagged push message

1 preset tag

Pigeon now offers the following three types of preset tags, and the game doesn't need to set additional tags:

Geographic location (provincial level)
App version
Lost user (3 days or 7 days)

2 set tag

1)Function description

The game can set tags for different users. A game can set a total of up to 10,000 tags. Each user can set up to 100 tags in a game. When setting a tag, note that the tag can not contain any space.

2)Interface declaration
void WGSetPushTag(string tag);
3)Parameter description
Parameter name Type Description
tag string it is not allowed to be null or contain any space
4)Return value

None

5)Demo code:
WGPlatform.Instance.WGSetPushTag("Student");
6)Special description

None

7)Term interpretation

None

3 delete tag

1)Function description

Delete the set user tag. When you push a message, the user will not be able to receive the push message under the tag.

2)Interface declaration
void WGDeletePushTag(string tag);
3)Parameter description
Parameter name Type Description
tag string it is not allowed to be null or contain any space
4)Return value

None

5)Demo code
WGPlatform.Instance.WGDeletePushTag("Student");
6)Special description

None

7)Term interpretation

None

4 Send the tagged push message

Sending the tagged push message is the same with Send push message. It only needs to choose personalized push for the covered crowd range when adding the push message, as shown in the following diagram:

iOS callback for clicking the push message

1)Function description

iOS TPNS push clicking callback, that is, `OnReceiveNotificationResponseNotify`, is provided. The converted json string of the `userInfo` field can be obtained through the callback. 3.3.26 version starts adding this interface

2)Demo code


//Set callback
MyObserver* ob = MyObserver::GetInstance();
WGPlatform::GetInstance()->WGSetObserver(ob);

//Callback example
void MyObserver::OnReceiveNotificationResponseNotify(const char *userInfo)
{
	...
}

Vendor Channel Push

1 Function description

Android vendor channel, a system-level push channel provided by Android smartphone vendors, can receive and display messages without launching App. This function can solve the problem that some vendors' smartphones cannot receive notifications when the process is killed, and improve the arrival rate of messages. Currently, vendor channels accessed and supported by MSDK Tencent Mobile Push include: Huawei, Xiaomi, Meizu and OPPO. Version 3.3.11 begins to add this capability.MSDK 3.3.255 has begun to remove Huawei, Xiaomi and vivo vendor channel-related capabilities; MSDK 3.3.256 has begun to remove Meizu vendor channel-related capabilities;MSDK version 3.3.28 updates TPNS to version 1.3.7.2 to restore the vendor channel push capability.

Unity 3.3.256.1 accessors need to manually delete the jar package of the TPNS vendor channel according to their own needs after updating and deploying MSDK. After deployment, the vendor channel SDK path is:

  • Huawei:/Assets/Msdk/Editor/Librarys/Android3.2/HWPushSDK
  • Other:/Assets/Msdk/Editor/Librarys/Android3.2/TPNSSDK/libs

For Unity 3.3.256.3 and later versions, MSDK has handled them automatically

2 Access configuration

TPNS vendor channel involves different vendors and there are a small amount of differences among the vendors, so its access process is relatively troublesome. After it is packaged by MSDK, developers only need to download SDK and add the corresponding configuration to access it. There are two main configuration items: client configuration and console configuration.

2.1 Client configuration

1) Add permissions and vendor channel component configuration to AndroidManifest.xml

For details, please refer to Vendor Channel Client Configuration (Search: Permission configuration for access to TPNS vendor channel, TPNS vendor channel component's configuration)

2) Configure vendor channel information and enable vendor channel functions

Open the msdkconfig.ini file in the 'assets' directory of the game project, and add relevant configuration information. For sources of the required appId and appKey, please refer to the TPNS official website description:

Huawei, Xiaomi, Meizu, OPPO

The reference example is as follows:

; Whether to enable the vendor channel, true: yes, false, no; the vendor channel is not enabled by default
XG_OTHER_PUSH_ENABLE=true
; Xiaomi channel's appid
XG_OTHER_PUSH_XIAOMI_APPID={ Xiaomi appId}
; Xiaomi channel's AppKey
XG_OTHER_PUSH_XIAOMI_APPKEY={ Xiaomi appKey}
; Meizu channel's appId
XG_OTHER_PUSH_MEIZU_APPID={ Meizu appId}
; Meizu channel's appKey
XG_OTHER_PUSH_MEIZU_APPKEY={ Meizu appKey}
; OPPO channel's appId (Note: fill in the appKey of OPPO channel)
XG_OTHER_PUSH_OPPO_APPID={OPPO appKey}
; OPPO channel's AppSecret
XG_OTHER_PUSH_OPPO_APPSECRET={OPPO appSecret}

Remarks:

  1. The appKey of Huawei channel needs to be configured in AndroidManifest.xml
  2. Fill in the appKey of the channel in the appId of the OPPO channel
3) Add Meizu notification icon

For low versions of Meizu smartphones (Meizu Flyme6.0 and below), you need to add an image named stat_sys_third_app_notify.png in the 'res/drawable' directory. The size of the image is generally 64*64. If there are multiple resolutions, it is recommended to add one image in each resolution.

If there is no such image, Meizu phones with low version may not display the message after receiving the message. Of course, if you don't consider Meizu low version phones, this step can be ignored.

4) Code obfuscation
-ignorewarning
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.android.hms.agent.**{*;}
-keep class com.xiaomi.**{*;}
-keep public class * extends com.xiaomi.mipush.sdk.PushMessageReceiver
-dontwarn com.meizu.cloud.pushsdk.**
-keep class com.meizu.cloud.pushsdk.**{*;}

2.2 Console configuration

You can configure the vendor channel by using Feiying system console or TPNS console directly, both of which need to be enabled in the vendor configuration and set the vendor channel.
Take Feiying system as an example. First, open the message management in your app and open the app configuration. The corresponding setting is as follows:

After the setting is completed, it will take effect within a few minutes to an hour.

3 Verification method

The verification process of each channel is the same. After the process is killed, that notifications are still received means that the function still works normally. Specific steps are as follows:

(1) Confirm that the relevant app information has been filled in "App Configuration - Vendor & Overseas Channels" in the Feiying system's TPNS management console. Generally, the relevant configuration will take effect in 1 hour. Please wait patiently and proceed to the next step after it takes effect.

(2) Install the integrated App (test version) on the test machine and run the App

(3) Keep the App running on the front-end, and try to push messages to a single device/all devices

(4) If the devices receive messages, what is to do next is to put the App to the backend and kill all App processes

(5) Perform single push/all push again. If the device can receive the push message, this indicates that the vendor channel integration is successful

4 Delete a vendor channel

Because a vendor channel needs to introduce a lot dependencies, games that do not require a vendor channel can delete the corresponding dependencies.

If you have configured AndroidManifest.xml and msdkconfig.ini, please refer to "2.1 Client configuration" instructions to restore them.

FAQ