Announcements
Features
SDK for Android
SDK for iOS
SDK for macOS
- (void)startXGWithAccessID:(uint32_t)accessID accessKey:(nonnull NSString *)accessKey delegate:(nullable id<XGPushDelegate>)delegate;
accessID: AccessID applied through the frontendaccessKey: AccessKey applied through the frontendDelegate: callback object[[XGPush defaultManager] startXGWithAccessID:<your AccessID> accessKey:<your AccessKey> delegate:self];
startXGWithAccessID:accessKey:delegate: method again to restart the TPNS service.- (void)stopXGNotification;
[[XGPush defaultManager] stopXGNotification];
@property (copy, nonatomic, nullable, readonly) NSString *xgTokenString;
NSString *token = [[XGPushTokenManager defaultTokenManager] xgTokenString];
- (void)xgPushDidRegisteredDeviceToken:(nullable NSString *)deviceToken xgToken:(nullable NSString *)xgToken error:(nullable NSError *)error
deviceToken: device token generated by APNs.xgToken: token generated by TPNS, which needs to be used during message push. TPNS maintains the mapping relationship between this value and the device token generated by APNs.error: error message. If error is nil, TPNS has been successfully registered.- (void)xgPushDidFailToRegisterDeviceTokenWithError:(nullable NSError *)error
- (void)xgPushDidRequestNotificationPermission:(bool)isEnable error:(nullable NSError *)error;
isEnable: whether authorization is approved or not.error: error message. If error is nil, the pop-up authorization result has been successfully obtained.- (void)upsertAccountsByDict:(nonnull NSDictionary<NSNumber *, NSString *> *)accountsDict;
xgPushDidRegisteredDeviceToken:error: returns a success.accountsDict: account dictionarykey is the account type and value is the account, for example, @{@(accountType):@"account"}.accountType values, see the XGPushTokenAccountType enumeration in the SDK demo package or Account Type Value Table.XGPushTokenAccountType accountType = XGPushTokenAccountTypeUNKNOWN;NSString *account = @"account";[[XGPushTokenManager defaultTokenManager] upsertAccountsByDict:@{ @(accountType):account }];
upsertAccountsByDict:@{@(1002):@"specific mobile number"}.- (void)upsertPhoneNumber:(nonnull NSString *)phoneNumber;
phoneNumber: an E.164 mobile number in the format of [+][country code or area code][mobile number], for example, +8613711112222. The SDK will encrypt the mobile number for transmission.[[XGPushTokenManager defaultTokenManager] upsertPhoneNumber:@"13712345678"];;
xgPushDidRegisteredDeviceToken:error: returns a success.delAccountsByKeys:[[NSSet alloc] initWithObjects:@(1002), nil] to delete a mobile number.- (void)delAccountsByKeys:(nonnull NSSet<NSNumber *> *)accountsKeys;
xgPushDidRegisteredDeviceToken:error: returns a success.accountsKeys: set of account typesaccountType, please see the enumerated values of XGPushTokenAccountType in the XGPush.h file in the SDK package.XGPushTokenAccountType accountType = XGPushTokenAccountTypeUNKNOWN;NSSet *accountsKeys = [[NSSet alloc] initWithObjects:@(accountType), nil];[[XGPushTokenManager defaultTokenManager] delAccountsByKeys:accountsKeys];
- (void)clearAccounts;
xgPushDidRegisteredDeviceToken:error: returns a success.[[XGPushTokenManager defaultTokenManager] clearAccounts];
- (void)appendTags:(nonnull NSArray<NSString *> *)tags- (void)delTags:(nonnull NSArray<NSString *> *)tags
xgPushDidRegisteredDeviceToken:error: returns a success.tags: tag arraytags is a tag string array, which cannot contain spaces or tabs.// Bind tags[[XGPushTokenManager defaultTokenManager] appendTags:@[ tagStr ]];// Unbind tags[[XGPushTokenManager defaultTokenManager] delTags:@[ tagStr ]];
- (void)clearAndAppendTags:(nonnull NSArray<NSString *> *)tags
xgPushDidRegisteredDeviceToken:error: returns a success.tags: tag arraytags is a tag string array, which cannot contain spaces or tabs.[[XGPushTokenManager defaultTokenManager] clearAndAppendTags:@[ tagStr ]];
- (void)clearTags
xgPushDidRegisteredDeviceToken:error: returns a success.[[XGPushTokenManager defaultTokenManager] clearTags];
- (void)queryTags:(NSUInteger)offset limit:(NSUInteger)limit;
xgPushDidRegisteredDeviceToken:error: returns a success.offset: the offset of this querylimit: the page size for this query; maximum value: 200[[XGPushTokenManager defaultTokenManager] queryTags:0 limit:100];
- (void)xgPushDidQueryTags:(nullable NSArray<NSString *> *)tags totalCount:(NSUInteger)totalCount error:(nullable NSError *)error;
tags: tags returned for the querytotalCount: total number of the tags bound to the deviceerror: error message. If error is nil, the query is successful.key-value structure (if there is no user attribute value corresponding to the key, it will add a new one; otherwise, it will update the value).- (void)upsertAttributes:(nonnull NSDictionary<NSString *,NSString *> *)attributes
xgPushDidRegisteredDeviceToken:error: returns a success.attributes: dictionary of user attribute strings, which cannot contain spaces or tabs.key and value can contain up to 50 characters.key is fixed.[[XGPushTokenManager defaultTokenManager] upsertAttributes:attributes];
- (void)delAttributes:(nonnull NSSet<NSString *> *)attributeKeys
xgPushDidRegisteredDeviceToken:error: returns a success.attributeKeys: set of user attribute keys, which cannot contain spaces or tabs.[[XGPushTokenManager defaultTokenManager] delAttributes:attributeKeys];
- (void)clearAttributes;
xgPushDidRegisteredDeviceToken:error: returns a success.[[XGPushTokenManager defaultTokenManager] clearAttributes];
- (void)clearAndAppendAttributes:(nonnull NSDictionary<NSString *,NSString *> *)attributes
xgPushDidRegisteredDeviceToken:error: returns a success.[[XGPushTokenManager defaultTokenManager] clearAndAppendAttributes:attributes];
- (void)setBadge:(NSInteger)badgeNumber;
badgeNumber: badge number of an applicationxgPushDidRegisteredDeviceToken).- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {/// Zero the badge number every time the application is started (you should set the local badge number for the application in the main thread)if ([XGPush defaultManager].xgApplicationBadgeNumber > 0) {[XGPush defaultManager].xgApplicationBadgeNumber = 0;}return YES;}- (void)xgPushDidRegisteredDeviceToken:(nullable NSString *)deviceToken xgToken:(nullable NSString *)xgToken error:(nullable NSError *)error {/// Sync the badge number to TPNS after registrationif (!error) {[[XGPush defaultManager] setBadge:0];}}
- (void)deviceNotificationIsAllowed:(nonnull void (^)(BOOL isAllowed))handler;
handler: result return method[[XGPush defaultManager] deviceNotificationIsAllowed:^(BOOL isAllowed) {<#code#>}];
- (nonnull NSString *)sdkVersion;
[[XGPush defaultManager] sdkVersion];
- (void)uploadLogCompletionHandler:(nullable void(^)(BOOL result, NSString * _Nullable errorMessage))handler;
@brief: report log information@param handler: report callback[[XGPush defaultManager] uploadLogCompletionHandler:nil];
XGPush > enableDebug.logInfo: log information- (void)xgPushLog:(nullable NSString *)logInfo;
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback