Configuring Extensions with Smartech SDK
Configuring Service Extension
You need to add the following changes in the Notification Service Extension's implementation file. NotificationService.m
#import "NotificationService.h"
#import <NetCorePush/NetCorePush.h>
@interface NotificationService ()
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
[[NetCoreNotificationService sharedInstance] setUpAppGroup:@"<USE_SAME_APPGROUP_USED_IN_APPDELEGATE>"];
[[NetCoreNotificationService sharedInstance] didReceiveNotificationRequest:request withContentHandler:^(UNNotificationContent *contentToDeliver) {
contentHandler(contentToDeliver);
}];
}
- (void)serviceExtensionTimeWillExpire {
[[NetCoreNotificationService sharedInstance] serviceExtensionTimeWillExpire];
}
@end
import UserNotifications
import NetCorePush
class NotificationService: UNNotificationServiceExtension {
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
NetCoreNotificationService.sharedInstance().setUpAppGroup("<USE_SAME_APPGROUP_USED_IN_APPDELEGATE>")
NetCoreNotificationService.sharedInstance().didReceive(request) { (contentToDeliver:UNNotificationContent) in
contentHandler(contentToDeliver)
}
}
override func serviceExtensionTimeWillExpire() {
NetCoreNotificationService.sharedInstance().serviceExtensionTimeWillExpire()
}
}
Configuring Content Extension
For Objective-C Project replace the following files from the file provided in Rich Files\ObjC Folder:
- MainInterface.storyboard
- NotificationViewController.h
- NotificationViewController.m
For Swift Project replace the following files from the file provided in Rich Files\Swift Folder:
- MainInterface.storyboard
- NotificationViewController.swift
In your Content Extensions Info.plist under NSExtension -> NSExtensionAttributes
- Replace the
UNNotificationExtensionCategory
value with String valuesmartechPushCategory
- Add the UNNotificationExtensionDefaultContentHidden key with Boolean value NO.
Updated over 4 years ago