Class Info |
|---|
public class HmsInstanceId Provides methods for obtaining an AAID and a token required for accessing Push Kit. |
Qualifier and Type | Method Name and Description |
|---|---|
NSString* | getAAID:(NSString *) Obtains an AAID. |
NSNumber* | getCreationTime:(NSNumber *) Obtains the generation timestamp of an AAID. |
void | deleteAAID:() Deletes a local AAID and its generation timestamp. |
NSString* | getToken:(NSString *) apnsToken Obtains a token required for accessing Push Kit. |
void | deleteToken:() Deletes a token required for accessing Push Kit. |
NSString* | getToken:(NSString *) apnsToken subjectId:(NSString*) subjectId Obtains a token that a target app developer applies for a sender to integrate Push Kit in the multi-sender scenario. |
void | deleteToken:(NSString *) subjectId Deletes a token that a target app developer applies for a sender to integrate Push Kit in the multi-sender scenario. |
Method |
|---|
- (NSString *)getAAID Obtains an AAID. |
Returns
Type | Description |
|---|---|
NSString* | An AAID string. |
Objective-C
#import <HmsPushSdk/HmsInstanceId.h>
NSString *aaid = [[HmsInstanceId getInstance] getAAID]; Swift
import HmsPushSdk
let aaid = HmsInstanceId.getInstance().getAAID(); Method |
|---|
- (NSNumber *)getCreationTime Obtains the generation timestamp of an AAID. |
Returns
Type | Description |
|---|---|
NSNumber* | A standard timestamp. |
Objective-C
#import <HmsPushSdk/HmsInstanceId.h>
NSNumber *createTime = [[HmsInstanceId getInstance] getCreationTime]; Swift
import HmsPushSdk
let createTimeStr=HmsInstanceId.getInstance().getCreationTime(); Objective-C
#import <HmsPushSdk/HmsInstanceId.h>
[[HmsInstanceId getInstance] deleteAAID]; Swift
import HmsPushSdk
HmsInstanceId.getInstance().deleteAAID(); Method |
|---|
- (NSString *)getToken:(NSString *) apnsToken Obtains a token required for accessing Push Kit. If there is no local AAID, this method will automatically generate an AAID when it is called because the Push Kit server needs to generate a token based on the AAID. |
Parameters
Name | Description |
|---|---|
apnsToken | Device token obtained from the APNs. The device token is the unique identifier of an iOS device. |
Returns
Type | Description |
|---|---|
NSString* | A token required for accessing Push Kit. |
Objective-C
#import <HmsPushSdk/HmsInstanceId.h>
NSString *apnsToken = @"yourApnsToken";
NSString *huaweiToken = [[HmsInstanceId getInstance] getToken:apnsToken]; Swift
import HmsPushSdk
let apnsToken = "yourApnsToken";
let huaweiToken = HmsInstanceId.getInstance().getToken(apnsToken); Method |
|---|
- (void)deleteToken Deletes a token required for accessing Push Kit. |
Objective-C
#import <HmsPushSdk/HmsInstanceId.h>
[[HmsInstanceId getInstance] deleteToken]; Swift
import HmsPushSdk
HmsInstanceId.getInstance().deleteToken(); Method |
|---|
- (NSString *)getToken:(NSString *) apnsToken subjectId:(NSString*) subjectId; Obtains a token that a target app developer applies for a sender to integrate Push Kit in the multi-sender scenario. The subjectId parameter needs to be passed to the sender project ID in AppGallery Connect. |
Parameters
Name | Description |
|---|---|
apnsToken | Device token obtained from the APNs. The device token is the unique identifier of an iOS device. |
subjectId | Project ID of the sender. Sign in to AppGallery Connect, select My projects, find your project in the project list, and go to Project settings. On the page that is displayed, obtain the project ID of the sender. |
Returns
Type | Description |
|---|---|
NSString* | A token required for accessing Push Kit. |
Objective-C
#import <HmsPushSdk/HmsInstanceId.h>
NSString *apnsToken = @"yourApnsToken";
NSString *projectId = @"yourProjectId";
NSString *huaweiToken = [[HmsInstanceId getInstance] getToken:apnsToken subjectId:projectId]; Swift
import HmsPushSdk
let projectID = "yourProjectId";
let apnsToken = "yourApnsToken";
let hwTokenSubProjectId = HmsInstanceId.getInstance().getToken(apnsToken,subjectId: projectID); Method |
|---|
- (void)deleteToken:(NSString *) subjectId Deletes a token that a target app developer applies for a sender to integrate Push Kit in the multi-sender scenario. The subjectId parameter needs to be passed to the sender project ID in AppGallery Connect. |
Parameters
Name | Description |
|---|---|
subjectId | Project ID of the sender. Sign in to AppGallery Connect, select My projects, find your project in the project list, and go to Project settings. On the page that is displayed, obtain the project ID of the sender. |
Objective-C
#import <HmsPushSdk/HmsInstanceId.h>
NSString* projectId = @"yourProjectId";
[[HmsInstanceId getInstance] deleteToken:projectId]; Swift
import HmsPushSdk
let projectID = "yourProjectId";
HmsInstanceId.getInstance().deleteToken(projectID);