Android aurora push alias and label method
- 2021-11-29 08:30:21
- OfStack
Android Aurora Push alias, label, RegistrationID
Description
Alias (alias)
For the user who installed the application, take an alias to identify it. This alias can be used to specify Push messages to the user later. You can only specify 1 alias per user.
Suggestion: For the same application, it is recommended that different users set different aliases to ensure the uniqueness of user aliases. (Aurora does not restrict the same alias to only one user. When a 1 alias specifies multiple users, when a message is pushed to this alias, multiple users corresponding to this alias will receive a push message)
Label (tag)
Labeling users is mainly used to push messages to specific batches of users. Multiple labels can be set for 1 user.
registrationId (Device Only 1 Identity)
When the application successfully registers with the Aurora server for the first time, the Aurora server will return a unique ID of the device-RegistrationID to the client. JPush SDK broadcasts RegistrationID to the application.
Applications can save this RegistrationID on their own application server, and then push messages or notifications to devices based on RegistrationID.
setMobileNumber
Version 3.1. 1 begins to provide an interface for setting mobile phone numbers, which is used for SMS supplementary function.
Supported operations
Alias and labels, support the operation of adding, deleting, modifying and checking.
registrationId, which only supports query operations.
Operation of alias:
Method - setAlias
Call this API to set the alias.
This interface is overlay logic, not incremental logic. That is, the new call overrides the previous setting.
public static void setAlias(Context context, int sequence, String alias);
Parameter definition
sequence
User-defined operation sequence number, returned from the operation result 1, is used to identify the uniqueness of one operation.
alias
Valid aliases: letters (case sensitive), numbers, underscores, Chinese characters, special character @! # $ & * + =..
Limit: alias naming length is limited to 40 bytes. (UTF-8 code is required for judging length)
Method - deleteAlias
Call this API to remove the alias.
public static void deleteAlias(Context context,int sequence);
Method - getAlias
Call this API to query the alias.
public static void getAlias(Context context,int sequence);
Operation of tag:
Method - setTags
Call this API to set the label.
It should be understood that this interface is overlay logic, not incremental logic. That is, the new call overrides the previous setting.
public static void setTags(Context context, int sequence,Set tags);
Parameter definition
sequence
User-defined operation sequence number, returned from the operation result 1, is used to identify the uniqueness of one operation.
tags
Valid label composition: letters (case sensitive), numbers, underscores, Chinese characters, special character @! # $ & * + =..
Limit: The named length of each tag is limited to 40 bytes, and up to 1000 tag can be set, and the total length of a single operation must not exceed 5000 bytes. (UTF-8 code is required for judging length)
Up to 1000 tag can be set up on a single device. There is no limit to the number of App global tag.
Method - addTags
Call this API to add a label.
public static void addTags(Context context, int sequence,Set tags);
Method - deleteTags
Call this API to delete the specified label.
public static void deleteTags(Context context, int sequence,Set tags);
sequence
0
Call this API to clear all tags.
public static void cleanTags(Context context, int sequence);
Method - getAllTags
Call this API to query all tags.
public static void getAllTags(Context context, int sequence);
Method - checkTagBindState
Call this API to query the state of the binding of the specified tag to the current user.
public static void checkTagBindState(Context context,int sequence,String tag);
Operation of registrationId
After the first registration of SDK is successful, the developer can obtain the corresponding RegistrationID by listening to Action-cn. jpush. android. intent. REGISTRATION in the custom Receiver.
After successful registration, it can also be obtained through the function public static String getRegistrationID (Context context)
Examples:
When the App terminal is registered successfully for the first time, or the getRegistrantionId interface obtains registrationId after the registration is successful, when the app logs in internally, the reference registrationId is transmitted, the server stores the current registrationId, and the server pushes the message according to the stored registrationId
Message callback mode description
Class - cn.jpush.android.service.JPushMessageReceiver
Related callback classes in the new message callback mode.
1. The new tag and alias operation callbacks will be triggered in the subclass of the class defined by the developer.
2. The callback of mobile phone number setting will be triggered in the subclass of this class defined by the developer.
This class is the parent class of callback. Developers need to inherit this class and configure your corresponding class in Manifest. The result of interface operation will be called back in the following method in the class you configured.
Method - onAliasOperatorResult
alias-related actions call back the results in this method.
Method - onTagOperatorResult
The operation of tag adding, deleting, checking and modifying will call back the result in this method.
Method - onCheckTagOperatorResult
An operation that queries the binding status of an tag to the current user calls back the result in this method.
Method - onMobileNumberOperatorResult
Setting the mobile phone number will call back the result in this method.
/**
* Customize JPush message Receiver , Include operations tag/alias Returns the result of ( Contains only tag/alias New interface section )
* */
public class MyJPushMessageReceiver extends JPushMessageReceiver {
@Override
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
super.onTagOperatorResult(context, jPushMessage);
}
@Override
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
super.onCheckTagOperatorResult(context, jPushMessage);
}
@Override
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
super.onAliasOperatorResult(context, jPushMessage);
}
@Override
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
super.onMobileNumberOperatorResult(context, jPushMessage);
}
}