startXGWithAppID API in the XGPush.h file in the SDK package.)/// @note Tencent Push Notification Service SDK v1.2.7.2 or later- (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 re-activate the service.- (void)stopXGNotification;
[[XGPush defaultManager] stopXGNotification];
@property (copy, nonatomic, nullable, readonly) NSString *xgTokenString;
NSString *token = [[XGPushTokenManager defaultTokenManager] xgTokenString];
xgPushDidRegisteredDeviceToken:error: returns a success.- (void)xgPushDidRegisteredDeviceToken:(nullable NSString *)deviceToken xgToken:(nullable NSString *)xgToken error:(nullable NSError *)error
deviceToken: device token generated by APNs.xgToken: token generated by Tencent Push Notification Service, which needs to be used during message push. Tencent Push Notification Service maintains the mapping relationship between this value and the device token generated by APNs.error: error message. If error is nil, Tencent Push Notification Service has been successfully registered./// @note Tencent Push Notification Service SDK v1.2.7.2 or later- (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"}./// @note Tencent Push Notification Service SDK v1.3.2.0+- (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:@"+8613712345678"];;
- (void)delAccountsByKeys:(nonnull NSSet<NSNumber *> *)accountsKeys;
xgPushDidRegisteredDeviceToken:error: returns a success.accountsKeys: set of account typesaccountType, 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 application/// Timing for calling a cold start- (void)xgPushDidRegisteredDeviceToken:(nullable NSString *)deviceToken xgToken:(nullable NSString *)xgToken error:(nullable NSError *)error {/// Report the badge number after registrationif (!error) {/// Reset the application badge. `-1`: Do not clear the notification bar; `0`: Clear the notification bar[XGPush defaultManager].xgApplicationBadgeNumber = -1;/// Reset the server badge base[[XGPush defaultManager] setBadge:0];}}/// Timing for calling a hot start/// The hot start tag `_launchTag` is managed by the business.- (void)xgPushNetworkConnected {if (_launchTag) {/// Reset the application badge. `-1`: Do not clear the notification bar; `0`: Clear the notification bar[XGPush defaultManager].xgApplicationBadgeNumber = -1;/// Reset the server badge base[[XGPush defaultManager] setBadge:0];_launchTag = NO;}}
/// Set the message polling time interval (minimum: 10s). This API should be called before the singleton initialization.- (void)setMessageTimerInterval:(NSTimeInterval)interval;
NSTimeInterval: NSTimeInterval type; the in-app message polling time interval.onClickWithCustomAction to handle related businesses./// Button event response proxy@property (weak, nonatomic, nullable) id<XGInAppMessageActionDelegate> actionDelegate;
- (void)deviceNotificationIsAllowed:(nonnull void (^)(BOOL isAllowed))handler;
handler: result return method[[XGPush defaultManager] deviceNotificationIsAllowed:^(BOOL isAllowed) {<#code#>}];
- (nonnull NSString *)sdkVersion;
[[XGPush defaultManager] sdkVersion];
/// @note Tencent Push Notification Service SDK v1.2.4.1+- (void)uploadLogCompletionHandler:(nullable void(^)(BOOL result, NSString * _Nullable errorMessage))handler;
@brief: report log information (SDK v1.2.4.1+).@param handler: report callback[[XGPush defaultManager] uploadLogCompletionHandler:nil];
XGPush > enableDebug.logInfo: log information- (void)xgPushLog:(nullable NSString *)logInfo;
+ (nullable id)actionWithIdentifier:(nonnull NSString *)identifier title:(nonnull NSString *)title options:(XGNotificationActionOptions)options;
identifier: unique ID of the action. title: action name. options: options supported by the action.XGNotificationAction *action1 = [XGNotificationAction actionWithIdentifier:@"xgaction001" title:@"xgAction1" options:XGNotificationActionOptionNone];
+ (nullable id)categoryWithIdentifier:(nonnull NSString *)identifier actions:(nullable NSArray<id> *)actions intentIdentifiers:(nullable NSArray<NSString *> *)intentIdentifiers options:(XGNotificationCategoryOptions)options
identifier: category object ID.actions: action object group included in the current category.intentIdentifiers: identifiers that can be recognized by Siri.options: category characteristics.XGNotificationCategory *category = [XGNotificationCategory categoryWithIdentifier:@"xgCategory" actions:@[action1, action2] intentIdentifiers:@[] options:XGNotificationCategoryOptionNone];
+ (nullable instancetype)configureNotificationWithCategories:(nullable NSSet<id> *)categories types:(XGUserNotificationTypes)types;
categories: a collection of categories supported by the notification bar. types: the style of the device registration notification.XGNotificationConfigure *configure = [XGNotificationConfigure configureNotificationWithCategories:[NSSet setWithObject:category] types:XGUserNotificationTypeAlert|XGUserNotificationTypeBadge|XGUserNotificationTypeSound];
Feedback