10/27/2025 18:02:26
Development of the Push Module
I. Plugin development
The push function can push game-related information to the player's mobile phone when the game is not running, such as various holiday activities, anniversary activities, etc.
Push methods are divided into local push and remote push
- Local push: the game generates push information by calling the local interface
- Remote push: send push information through the management console of the push channel
Push information is divided into in-app message and notification bar information
- In-app message: the information inside the app, which will not be displayed in the notification bar (iOS does not have this type)
- Notification bar information: the information which will be displayed in the notification bar
[info] Callback description of the Push module
- Each method is recommended to be called back with the unified callback processing method, and there is only one callback (adding local push notification and clearing the local push notification method cannot give any callback)
- In addition to the basic method call callbacks, the Push module needs to give push-related callbacks
- General Message Callbacks
- Push display callback, which is the callback generated when the push message is displayed, including local push and remote push
- Push click callback, which is the callback generated when the push message is clicked by the user, including local push and remote push
II. Client Plugin Development
2.1 Android Platform
2.1.1 Class implementation rules
- Package naming rule: fixed as
com.tencent.gcloud.msdk.push - Class naming rule:
channel + Push, such as:XGFriend - Must implement the
PushInterfaceinterfaceregisterPushfunction, which is used to register the channel's push function. The device can receive message push from the channel after registering the push function successfullyunregisterPushfunction, which is used to unregister the channel's push function. The device can't receive message push from the channel after unregistering the push function successfullysetTagfunction, which is used to set tags and can set different tags for different users, used to push different messages for different user tagsdeleteTagfunction, which is used to delete tags, that is, to delete user tags that have been setaddLocalNotificationfunction, which is used to add local push messageclearLocalNotificationsfunction, which is used to clear all local push messagessetAccountfunction, which is used to set the user's account to support message push by accountdeleteAccountfunction, which is used to delete the account set by the user
- Must implement a
public CLASSNAME ()constructor, which is usually used for plugin initialization
2.1.2 Description of callback fields
As for the description of the callback function, please refer to Client Plugin Development Rules
observerIDcallback function IDMSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGEis used to return the call result of the push methodMSDKObserverID.MSDK_PUSH_OBSERVER_NOTIFICATIONis used to return the message results related to push message
retreturn struct must be a subclass ofMSDKRetMSDKRet, the basic call result class, which is the method call result return struct in the Push moduleMSDKPushRet, the push message result class, which is the result return struct related to push messages in the Push module. In addition to the basic result parameters,InnerPushRetalso includes:type- 0 - Remote notification received by the app is in the front end
- 1 - Remote notification received by the app in the backend
- 2 - Local notification received by the app is in the front end
- 3 - Local notification received by the app in the backend
- If not sure, please fill in -1
notification, the content of the notification
methodNameIDFunction ID defined by MSDK, used to define the callback method- Basic calling methods
MSDKMethodNameID.MSDK_PUSH_REGISTER_PUSHis the method ID of registering the channel pushMSDKMethodNameID.MSDK_PUSH_UNREGISTER_PUSHis the method ID of unregistering the deviceMSDKMethodNameID.MSDK_PUSH_SET_ACCOUNTis the account setting method IDMSDKMethodNameID.MSDK_PUSH_DELETE_ACCOUNTis the account deleting method IDMSDKMethodNameID.MSDK_PUSH_SET_TAGis the tag setting method IDMSDKMethodNameID.MSDK_PUSH_DELETE_TAGis the tag deleting method IDMSDKMethodNameID.MSDK_PUSH_ADD_LOCAL_NOTIFICATIONis the method ID of adding local pushMSDKMethodNameID.MSDK_PUSH_CLEAR_LOCAL_NOTIFICATIONis the method ID of clearing all local pushes
- Push callback methods
MSDKMethodNameID.MSDK_PUSH_TEXT_MESSAGEis the general message callback IDMSDKMethodNameID.MSDK_PUSH_NOTIFICATION_SHOWis the push display callback IDMSDKMethodNameID.MSDK_PUSH_NOTIFICATION_CLICKis the push click callback ID
- Basic calling methods
[info] Precautions
For the Android platform, you can distinguish in-app message callbacks, push display and push clicks, so you need to distinguish the MethodID of the callbacks. The universal message callback can be used for the callback of receiving messages in the app, including local app messages and remote app messages.
2.1.3 PushInterface interface
registerPush function
Register the channel's push function. After the registration is successful, the device can receive message push, including the case that the device re-registers the function after unregistering it
@Override public void registerPush(String account,String seqID) { // The channel's push registration logic ... // Return "Register push successfully" MSDKRet result = new MSDKRet(MSDK_PUSH_REGISTER_PUSH, MSDKErrorCode.SUCCESS); IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }unregisterPush function
The device unregistering function. The device will not receive message push after unregistering the push function successfully.
@Override public void unregisterPush(String seqID) { // The device unregistering logic ... // Return "Unregister device successfully" MSDKRet result = new MSDKRet(MSDK_PUSH_UNREGISTER_PUSH, MSDKErrorCode.SUCCESS); IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }setAccount function
The account setting function. Set the user's account to support pushing messages by account
@Override public void setAccount(String account, String seqID ) { // The account setting logic of the channel ... // Return "Set account successfully" MSDKRet result = new MSDKRet(MSDK_PUSH_SET_ACCOUNT, MSDKErrorCode.SUCCESS); IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }deleteAccount function
The account deleting function. Delete the user's account that has been set.
@Override public void deleteAccount(String account, String seqID) { // The account deleting logic of the channel ... // Return "Delete account successfully" MSDKRet result = new MSDKRet(MSDK_PUSH_DELETE_ACCOUNT, MSDKErrorCode.SUCCESS); IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }setTag function
The label setting function. Different tags can be set for different users to push different messages to different users according to their tags.
@Override public void setTag(String tag, String seqID) { // The tag setting logic of the channel ... // Return "Set the tag successfully" MSDKRet result = new MSDKRet(MSDK_PUSH_SET_TAG, MSDKErrorCode.SUCCESS); IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }deleteTag function
The tag deleting function. Delete the user's tag that has been set.
@Override public void deleteTag(String tag, String seqID) { // The tag deleting logic of the channel ... // Return "Delete the tag successfully" MSDKRet result = new MSDKRet(MSDK_PUSH_DELETE_TAG, MSDKErrorCode.SUCCESS); IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }addLocalNotification function
The function of adding local push messages.
@Override public void addLocalNotification(MSDKLocalNotification localNotification, String seqID) { // The channel's logic of adding local push messages ... // [Optional] Return "Add local push messages successfully" // MSDKRet result = new MSDKRet(MSDK_PUSH_ADD_LOCAL_NOTIFICATION, MSDKErrorCode.SUCCESS); // IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }clearLocalNotifications function
Clear all local pushes.
@Override public void clearLocalNotifications(String seqID) { // The channel's logic of clearing all local pushes ... // [Optional] Return "Clear all local pushes successfully" // MSDKRet result = new MSDKRet(MSDK_PUSH_CLEAR_LOCAL_NOTIFICATION, MSDKErrorCode.SUCCESS); // IT.onPluginRetCallback(MSDKObserverID.MSDK_PUSH_OBSERVER_DELIVER_MESSAGE, result, seqID); }
[info] For details, please refer to Demo Code
2.2 iOS Platform
2.2.1 Class rule description
- Naming rules: Fixed as
MSDKPush + channel, such as:MSDKPushXG - Must implement the
MSDKPushDelegateprotocolregisterPushfunction, which is used to register the channel's push function. The device can receive message push from the channel after registering the push function successfullyunregisterPushfunction, which is used to unregister the channel's push function. The device can't receive message push from the channel after unregistering the push function successfullysetTagfunction, which is used to set tags and can set different tags for different users, used to push different messages for different user tagsdeleteTagfunction, which is used to delete tags, that is, to delete user tags that have been setsetAccountfunction, which is used to set the user's account to support message push by accountdeleteAccountfunction, which is used to delete the account set by the user- Note: Add the local push. The method of the local push has been provided by MSDK on the iOS platform. It does not need to be implemented by the channel's plugin itself, but the channel's plugin needs to provide the monitoring method of local push and give a callback when a local push is received.
2.2.2 Description of callback fields
As for the description of the callback function, please refer to Client Plugin Development Rules
observerID: the callback function IDkObserverIDPushBaseRetis used to return the call result of the push methodkObserverIDPushNotifyCallbackis used to return the message results related to push message
ret: the callback result- The
rettype of the Push module includes:InnerBaseRet, which is used to return the call result of the push methodInnerPushRet, which is used to return the results related to push messages. In addition to the basic result parameters,InnerPushRetalso includes:type- 0 - Remote notification received by the app is in the front end
- 1 - Remote notification received by the app in the backend
- 2 - Local notification received by the app is in the front end
- 3 - Local notification received by the app in the backend
- If not sure, please fill in -1
notification, the content of the notification
- The
methodNameIDFunction ID defined by MSDK, used to define the callback method- Basic calling methods
kMethodNameRegisterPushis the method ID of registering the channel pushkMethodNameUnregisterPushis the method ID of unregistering the devicekMethodNameSetAccountPushis the account setting method IDkMethodNameDeleteAccountPushis the account deleting method IDkMethodNameSetTagForPushis the tag setting method IDkMethodNameDeleteTagForPushis the tag deleting method IDkMethodNameAddLocalNotifyis the method ID of adding local pushkMethodNameClearLocalNotifyis the method ID of clearing all local pushes
- Push callback methods
kMethodNameNotifyCallbackis the general message callback IDkMethodNameNotifyShowis the push display callback IDkMethodNameNotifyClickis the push click callback ID
- Basic calling methods
[info] Precautions
For the iOS platform, because there is no way to distinguish display and click callbacks, a universal callback can be used for callbacks
2.2.3 MSDKPushDelegate protocol
registerPush function
Register the channel's push function. After the registration is successful, the device can receive message push, including the case that the device re-registers the function after unregistering it
- (void)registerPush:(const MSDKBaseParams &)baseParams withAccount:(const std::string &)account { // The channel's push registration logic ... // Return "Register push successfully" InnerBaseRet ret(MSDKError::SUCCESS); ret.methodNameID = kMethodNameRegisterPush; MSDKInnerObserverHolder<InnerBaseRet>::CommitToTaskQueue(ret, kObserverIDPushBaseRet, baseParams.seqID); }unregisterPush function
The device unregistering function. The device will not receive message push after unregistering the push function successfully.
- (void)unregisterPush:(const MSDKBaseParams &)baseParams { // The device unregistering logic ... // Return "Unregister device successfully" InnerBaseRet ret(MSDKError::SUCCESS); ret.methodNameID = kMethodNameUnregisterPush; MSDKInnerObserverHolder<InnerBaseRet>::CommitToTaskQueue(ret, kObserverIDPushBaseRet, baseParams.seqID); }setAccount function
The account setting function. Set the user's account to support pushing messages by account
- (void)setAccount:(const MSDKBaseParams &)baseParams withAccount:(const std::string &)account { // The account setting logic of the channel ... // Return "Set account successfully" InnerBaseRet ret(MSDKError::SUCCESS); ret.methodNameID = kMethodNameSetAccountPush; MSDKInnerObserverHolder<InnerBaseRet>::CommitToTaskQueue(ret, kObserverIDPushBaseRet, baseParams.seqID); }deleteAccount function
The account deleting function. Delete the user's account that has been set.
- (void)deleteAccount:(const MSDKBaseParams &)baseParams withAccount:(const std::string &)account { // The account deleting logic of the channel ... // Return "Delete account successfully" InnerBaseRet ret(MSDKError::SUCCESS); ret.methodNameID = kMethodNameDeleteAccountPush; MSDKInnerObserverHolder<InnerBaseRet>::CommitToTaskQueue(ret, kObserverIDPushBaseRet, baseParams.seqID); }setTag function
The label setting function. Different tags can be set for different users to push different messages to different users according to their tags.
- (void)setTag:(const MSDKBaseParams &)baseParams withTag:(const std::string &)tag { // The tag setting logic of the channel ... // Return "Set the tag successfully" InnerBaseRet ret(MSDKError::SUCCESS); ret.methodNameID = kMethodNameSetTagForPush; MSDKInnerObserverHolder<InnerBaseRet>::CommitToTaskQueue(ret, kObserverIDPushBaseRet, baseParams.seqID); }deleteTag function
The tag deleting function. Delete the user's tag that has been set.
- (void)deleteTag:(const MSDKBaseParams &)baseParams withTag:(const std::string &)tag { // The tag deleting logic of the channel ... // Return "Delete the tag successfully" InnerBaseRet ret(MSDKError::SUCCESS); ret.methodNameID = kMethodNameDeleteTagForPush; MSDKInnerObserverHolder<InnerBaseRet>::CommitToTaskQueue(ret, kObserverIDPushBaseRet, baseParams.seqID); }
[info] For details, please refer to Demo Code
All rights reserved.