After the service of reading SMS messages is enabled, the SMS message you obtain is as follows:
prefix_flag short message verification code is XXXXXX hash_valueprefix_flag indicates the prefix of an SMS message, which can be <#>, [#], or \u200b\u200b. \u200b\u200b are invisiable Unicode characters. short message verification code is indicates the content of an SMS message, which is user-defined. XXXXXX indicates the verification code. hash_value indicates the hash value generated by the HMS SDK based on your app package name to uniquely identify your app, please refer to Obtain Hash_value.
| Type | Name | Desc |
| Return type | Method name |
| Task<Void> | start(Activity activity) Enables the service of reading SMS messages until the SMS messages that meet the rules (Timeout five minutes). If error code 2021 is returned, the HUAWEI ID does not support the function of reading SMS messages. |
| Task<Void> | start(Context context) Enables the service of reading SMS messages until the SMS messages that meet the rules (Timeout five minutes). If error code 2021 is returned, the HUAWEI ID does not support the function of reading SMS messages. |
| Constant |
| Constant |
Parameters
| Parameter name | Parameter desc |
| activity | Activity used to display the SMS authorization dialog box. |
Return
| type | desc |
| Task<Void> | The Task object is returned, which is used to check whether a request is successful, fails, or is completed. You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance. |
Parameters
| Parameter name | Parameter desc |
| context | Context used to display the SMS authorization dialog box. |
Return
| type | desc |
| Task<Void> | The Task object is returned, which is used to check whether a request is successful, fails, or is completed. You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance. |