Description for using notification service extension

Last updated: 2019-12-04 14:42:22



In iOS 10.0+, the operating system provides the Service Extension API, which can be called by the client to listen to the arrival of messages.

SDK statistics reporting APIs

Reporting on receipt of push messages. This API is used to track statistics of whether push messages reach devices.

 @brief: The TPNS messages that arrive to the end terminal, that is, message receipt

 @param request: Push request
 @param appID: TPNS application ID
 @param appKey: TPNS application Key
 @param handler: process the associated rich media file in callback method.
- (void)handleNotificationRequest:(nonnull UNNotificationRequest *)request appID:(uint32_t)appID appKey:(nonnull NSString *)appKey contentHandler:(nullable void(^)( NSArray <UNNotificationAttachment *>* _Nullable attachments,  NSError * _Nullable error))handler;

Parameter descriptions

  • request: push request.
  • AppID: TPNS application ID.
  • handler: process the associated rich media file in callback method.


Perform the following steps to use the extension SDK:

  1. In the xcode menu bar, select File > New > Target.
  2. Enter the Target page, select Notification Service Extension and click Next.
  3. Enter Product Name and click Finish.
  4. Configure Target and add the dependent library files: libXGExtension.a, libz.tbd, libsqlite3.tbd.
  5. Call the SDK statistics reporting API. Sample code is as follows:
     - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
             self.contentHandler = contentHandler;
             self.bestAttemptContent = [request.content mutableCopy];
             [[XGExtension defaultManager] handleNotificationRequest:request appID:<#appid#> appKey:<#appkey#>  contentHandler:^(NSArray<UNNotificationAttachment *> * _Nullable attachments, NSError * _Nullable error) {
                     self.bestAttemptContent.attachments = attachments;