Mobile Push Service (MPS) provides client APIs to bind and unbind user-device pairs and report third-party channel devices.
|
Call method |
API |
Description |
|
RPC call |
Binds a user ID and a device ID (Ad-token). |
|
|
Unbinds a user ID and a device ID (Ad-token). |
||
|
Binds a third-party channel device ID (Ad-token). |
The MPPush class in the mPaaS middle layer encapsulates all MPS APIs, including bind, unbind, and third-party channel device reporting. The mobile gateway SDK implements RPCs for these methods.
Bind
-
Method definition
Binds a user ID to a device ID, enabling push messages to specific users. Call this method in a subthread.
public static ResultPbPB bind(Context ctx, String userId, String token) -
Parameters
Parameter
Type
Description
ctx
Context
A non-empty
Context.userId
String
A unique user identifier. Does not need to be the actual user system ID, but must map one-to-one to a user.
token
String
The device ID issued by the MPS gateway.
-
Return value
Parameter
Description
success
Whether the API call succeeded.
-
true: The call succeeded.
-
false: The call failed.
code
The operation result code.
name
The result code name.
message
The result code description.
Result code description
Result code
Result code name
Message
Description
3012
NEED_USERID
need userid
The input parameter
userIdis empty.3001
NEED_DELIVERYTOKEN
need token
The input parameter
tokenis empty. -
-
Example
private void doSimpleBind() { final ResultPbPB resultPbPB = MPPush.bind(getApplicationContext(), mUserId, PushMsgService.mAdToken); handlePbPBResult("Bind user operation", resultPbPB); }
Unbind
-
Method definition
Unbinds a user ID from a device ID. Call this method in a subthread.
public static ResultPbPB unbind(Context ctx, String userId, String token) -
Parameters
Parameter
Type
Description
ctx
Context
A non-empty Context.
userId
String
A unique user identifier. Does not need to be the actual user system ID, but must map one-to-one to a user.
token
String
The device ID issued by the MPS gateway.
-
Return value
Same return value as the bind method.
-
Example
private void doSimpleUnBind() { final ResultPbPB resultPbPB = MPPush.unbind(getApplicationContext() , mUserId, PushMsgService.mAdToken); handlePbPBResult("Unbind user operation", resultPbPB); }
Report third-party channel device
-
Method definition
Reports the third-party channel device ID and the mPaaS Ad-token to the MPS core, which synchronously binds the two identifiers. After binding, you can push messages through the third-party channel.
The framework calls this method internally. Call it again manually to prevent potential SDK call failures.
public static ResultPbPB report(Context context, String deliveryToken, int thirdChannel, String thirdChannelDeviceToken) -
Parameters
Parameter
Type
Description
ctx
Context
A non-empty Context.
deliveryToken
String
The device ID (Ad-token) issued by the MPS gateway.
thirdChannel
int
The third-party channel. Valid values:
-
2: Apple
-
4: Xiaomi
-
6: FCM
-
7: OPPO
-
8: vivo
thirdChannelDeviceToken
String
The device ID of the vendor channel.
-
-
Return value
Same return value as the bind method.
-
Example
private void doSimpleUploadToken() { final ResultPbPB resultPbPB = MPPush.report(getApplicationContext(), PushMsgService.mAdToken , PushOsType.HUAWEI.value(), PushMsgService.mThirdToken); handlePbPBResult("Third-party push identifier reporting operation", resultPbPB);
Troubleshooting
If an exception occurs during an RPC call, troubleshoot using Security Guard result code description.