From ba429280b3f3c7dc5ffa193944c5d38df07c6c3f Mon Sep 17 00:00:00 2001 From: Jenna Antilla <46546946+jennantilla@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:42:42 -0700 Subject: [PATCH] Remove NotificationService file updates --- MIGRATION_GUIDE.md | 87 +--------------------------------------------- 1 file changed, 1 insertion(+), 86 deletions(-) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index f6c23f5c..2a23d90a 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -47,92 +47,7 @@ In your Project Root > ios > Podfile, update the notification service extension: end ``` -Close Xcode. While still in the ios directory, run `pod install` again. - -Re-Open the `. xcworkspace` file in Xcode. In the OneSignalNotificationServiceExtension directory > `NotificationService.m` or `NotificationService.swift` file, replace the whole file contents with the code below: - -**Objective-C** -```objc -#import - -#import "NotificationService.h" - -@interface NotificationService () - -@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); -@property (nonatomic, strong) UNNotificationRequest *receivedRequest; -@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent; - -@end - -@implementation NotificationService - -- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { - self.receivedRequest = request; - self.contentHandler = contentHandler; - self.bestAttemptContent = [request.content mutableCopy]; - - /* DEBUGGING: Uncomment the 2 lines below and comment out the one above to ensure this extension is executing - Note, this extension only runs when mutable-content is set - Setting an attachment or action buttons automatically adds this */ - // NSLog(@"Running NotificationServiceExtension"); - // self.bestAttemptContent.body = [@"[Modified] " stringByAppendingString:self.bestAttemptContent.body]; - - [OneSignalExtension didReceiveNotificationExtensionRequest:self.receivedRequest - withMutableNotificationContent:self.bestAttemptContent - withContentHandler:self.contentHandler]; -} - -- (void)serviceExtensionTimeWillExpire { - // Called just before the extension will be terminated by the system. - // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. - - [OneSignalExtension serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent]; - - self.contentHandler(self.bestAttemptContent); -} - -@end -``` - -**Swift** -```swift -import UserNotifications - -import OneSignalExtension - -class NotificationService: UNNotificationServiceExtension { - - var contentHandler: ((UNNotificationContent) -> Void)? - var receivedRequest: UNNotificationRequest! - var bestAttemptContent: UNMutableNotificationContent? - - override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { - self.receivedRequest = request - self.contentHandler = contentHandler - self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) - - if let bestAttemptContent = bestAttemptContent { - /* DEBUGGING: Uncomment the 2 lines below to check this extension is executing - Note, this extension only runs when mutable-content is set - Setting an attachment or action buttons automatically adds this */ - // print("Running NotificationServiceExtension") - // bestAttemptContent.body = "[Modified] " + bestAttemptContent.body - - OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler) - } - } - - override func serviceExtensionTimeWillExpire() { - // Called just before the extension will be terminated by the system. - // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. - if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { - OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent) - contentHandler(bestAttemptContent) - } - } -} -``` +Close Xcode. While still in the ios directory, run `pod install --repo-update`. # API Changes