doc folder: contains the development guide of the TPNS SDK for iOS.demo folder: contains demo projects and the TPNS SDK (only the OC demo is included. For the Swift demo, please go to TGit).


AccessID and AccessKey from the application information column.pod 'TPNS-iOS', '~> version' // If the version is not specified, the latest version of the local pod `TPNS-iOS` will be downloaded
Unable to find a specification for 'TPNS-iOS', you need to run the following command to update the repository and confirm the version:pod repo updatepod search TPNS-iOSpod install // Install the SDK
* XGInAppMessage.framework* XGMTACloud.framework* CoreTelephony.framework* SystemConfiguration.framework* UserNotifications.framework* libXG-SDK-Cloud.a* libz.tbd* CoreData.framework* CFNetwork.framework* libc++.tbd


Time Sensitive Notifications in Capabilities.
-ObjC.

checkTargetOtherLinkFlagForObjc reports an error, it means that -ObjC has not been added to Other link flags in build setting.tpns.tencent.com.XGPushPrivate.h file in the SDK directory to the project, and reference to it (#import "XGPushPrivate.h") in the class that needs to configure the domain name.startXGWithAccessID:accessKey:delegate: method.tpns.sh.tencent.com.
Example/// @note TPNS SDK1.2.7.1+ [[XGPush defaultManager] configureClusterDomainName:@"tpns.sh.tencent.com"];
tpns.sgp.tencent.com./// @note TPNS SDK1.2.7.1+[[XGPush defaultManager] configureClusterDomainName:@"tpns.sgp.tencent.com"];
tpns.hk.tencent.com.
Example/// @note TPNS SDK1.2.7.1+[[XGPush defaultManager] configureClusterDomainName:@"tpns.hk.tencent.com"];
tpns.tencent.com.
Example/// @note TPNS SDK1.2.7.1+[[XGPush defaultManager] configureClusterDomainName:@"tpns.tencent.com"];
XGPushDelegate protocol as needed to launch the push service.AppDelegate sample is as follows:@interface AppDelegate () <XGPushDelegate>@end/**@param AccessID //`AccessID` applied for in the TPNS console@param AccessKey //`AccessKey` applied for in the TPNS console@param delegate //Callback object**/-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{[[XGPush defaultManager] startXGWithAccessID:<your AccessID> accessKey:<your AccessKey> delegate:self];return YES;}
AppDelegate, choose to implement the method in the XGPushDelegate protocol:/// Unified callback for message receipt/// @param notification //Message object (there are two types: `NSDictionary` and `UNNotification`. For detailed interpretations, please see the sample code)/// @note //This callback is the callback for receipt of notification messages in the foreground and silent messages in all states (unified message click callback should be used for message clicks)/// Message type description: if `msgtype` in the `xg` field is `1`, it means notification message; if `msgtype` is `2`, it means silent message.- (void)xgPushDidReceiveRemoteNotification:(nonnull id)notification withCompletionHandler:(nullable void (^)(NSUInteger))completionHandler{/// code}/// Unified message click callback/// @param response //`UNNotificationResponse` for iOS 10+ and macOS 10.14+, or `NSDictionary` for earlier versions- (void)xgPushDidReceiveNotificationResponse:(nonnull id)response withCompletionHandler:(nonnull void (^)(void))completionHandler {/// code}
// Enable debugging[[XGPush defaultManager] setEnableDebug:YES];
XGPushDelegate protocol/**@brief //Callback for TPNS registration@param deviceToken //`Device Token` generated by APNs@param 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@param error //Error message. If `error` is `nil`, the push service has been successfully registered@note TPNS SDK1.2.6.0+*/- (void)xgPushDidRegisteredDeviceToken:(nullable NSString *)deviceToken xgToken:(nullable NSString *)xgToken error:(nullable NSError *)error;/// Callback for TPNS registration failure/// @param error //Error message for registration failure/// @note TPNS SDK1.2.7.1+- (void)xgPushDidFailToRegisterDeviceTokenWithError:(nullable NSError *)error {}
[TPNS] Current device token is 9298da5605c3b242261b57****376e409f826c2caf87aa0e6112f944[TPNS] Current TPNS token is 00c30e0aeddff1270d8****dc594606dc184
- (void)xgPushDidReceiveRemoteNotification:(nonnull id)notification withCompletionHandler:(nullable void (^)(NSUInteger))completionHandler;
if ([notification isKindOfClass:[UNNotification class]]) {completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);}
xgPushDidReceiveRemoteNotification will be triggered.
The following is the sample code for differentiating the receipt of a notification message in the foreground or a silent message in all states.NSDictionary *tpnsInfo = notificationDic[@"xg"];NSNumber *msgType = tpnsInfo[@"msgtype"];if (msgType.integerValue == 1) {/// Receipt of a notification message in the foreground} else if (msgType.integerValue == 2) {/// Receipt of a silent message} else if (msgType.integerValue == 9) {/// Receipt of a local notification (TPNS local notification)}
/// Unified message click callback/// @param response will be `UNNotificationResponse` for iOS 10+/macOS 10.14+, or `NSDictionary` for earlier versions./// @note TPNS SDK1.2.7.1+- (void)xgPushDidReceiveNotificationResponse:(nonnull id)response withCompletionHandler:(nonnull void (^)(void))completionHandler;
xgPushDidReceiveRemoteNotification of the TPNS will process message receipt and then automatically call the application:didReceiveRemoteNotification:fetchCompletionHandler method, which, however, may also be hooked by other SDKs.application:didReceiveRemoteNotification:fetchCompletionHandler method, please see the following guidelines to avoid repeated service processing:xg field to tell whether it is a TPNS message. If it is a TPNS message, process it using the xgPushDidReceiveRemoteNotification method; otherwise, process it using the application:didReceiveRemoteNotification:fetchCompletionHandler method.xgPushDidReceiveRemoteNotification and application:didReceiveRemoteNotification:fetchCompletionHandler are executed, then completionHandler needs to be called only once in total. If it is also called by other SDKs, make sure that it is called only once overall; otherwise, crashes may occur.// Get the token generated by TPNS.[[XGPushTokenManager defaultTokenManager] xgTokenString];
[[XGPush defaultManager] uploadLogCompletionHandler:^(BOOL result, NSString * _Nullable errorMessage) {NSString *title = result ? NSLocalizedString(@"report_log_info", nil) : NSLocalizedString(@"failed", nil);if (result && errorMessage.length>0) {UIPasteboard *pasteboard = [UIPasteboardgeneralPasteboard];pasteboard.string = errorMessage;}[TPNSCommonMethodshowAlert:title message:errorMessage viewController:selfcompletion:nil];}];
フィードバック