-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd7ad6b
commit ab32785
Showing
16 changed files
with
1,100 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
#import "AppDelegate.h" | ||
#import "GeneratedPluginRegistrant.h" | ||
#import <SyneriseSDK/SyneriseSDK.h> | ||
|
||
@implementation AppDelegate | ||
|
||
- (BOOL)application:(UIApplication *)application | ||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
[GeneratedPluginRegistrant registerWithRegistry:self]; | ||
// Override point for customization after application launch. | ||
return [super application:application didFinishLaunchingWithOptions:launchOptions]; | ||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
UNNotificationCategory *singleMediaCategory = [UNNotificationCategory categoryWithIdentifier:SNRSingleMediaContentExtensionViewControllerCategoryIdentifier actions:@[] intentIdentifiers:@[] options:0]; | ||
|
||
UNNotificationAction *carouselPreviousAction = [UNNotificationAction actionWithIdentifier:SNRCarouselContentExtensionViewControllerPreviousItemIdentifier title:@"Previous" options:0]; | ||
|
||
UNNotificationAction *carouselGoAction = [UNNotificationAction actionWithIdentifier:SNRCarouselContentExtensionViewControllerChooseItemIdentifier title:@"Go" options:0]; | ||
|
||
UNNotificationAction *carouselNextAction = [UNNotificationAction actionWithIdentifier:SNRCarouselContentExtensionViewControllerNextItemIdentifier title:@"Next" options:0]; | ||
|
||
UNNotificationCategory *carouselCategory = [UNNotificationCategory categoryWithIdentifier:SNRCarouselContentExtensionViewControllerCategoryIdentifier actions:@[carouselPreviousAction, carouselGoAction, carouselNextAction] intentIdentifiers:@[] options:0]; | ||
|
||
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:singleMediaCategory, carouselCategory, nil]]; | ||
|
||
|
||
[GeneratedPluginRegistrant registerWithRegistry:self]; | ||
// Override point for customization after application launch. | ||
|
||
return [super application:application didFinishLaunchingWithOptions:launchOptions]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
example/ios/SyneriseCarouselNotificationContentExtension/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionAttributes</key> | ||
<dict> | ||
<key>UNNotificationExtensionCategory</key> | ||
<array> | ||
<string>synerise.notifications.category.carousel</string> | ||
</array> | ||
<key>UNNotificationExtensionDefaultContentHidden</key> | ||
<true/> | ||
<key>UNNotificationExtensionInitialContentSizeRatio</key> | ||
<real>1</real> | ||
</dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.usernotifications.content-extension</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).NotificationViewController</string> | ||
</dict> | ||
</dict> | ||
</plist> |
25 changes: 25 additions & 0 deletions
25
example/ios/SyneriseCarouselNotificationContentExtension/NotificationViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// NotificationViewController.swift | ||
// SyneriseCarouselNotificationContentExtension | ||
// | ||
// Created by Krzysztof Kurzawa on 29/06/2023. | ||
// | ||
|
||
import UIKit | ||
import UserNotifications | ||
import UserNotificationsUI | ||
import SyneriseSDK | ||
|
||
class NotificationViewController: CarouselContentExtensionViewController, UNNotificationContentExtension { | ||
|
||
func didReceive(_ notification: UNNotification) { | ||
Synerise.settings.sdk.appGroupIdentifier = "group.com.synerise.sdk.flutter" | ||
Synerise.settings.sdk.keychainGroupIdentifier = "34N2Z22TKH.FlutterKeychainGroup" | ||
|
||
setSyneriseNotification(notification) | ||
} | ||
|
||
func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) { | ||
setSyneriseNotificationResponse(response, completionHandler: completion) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...selNotificationContentExtension/SyneriseCarouselNotificationContentExtension.entitlements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.application-groups</key> | ||
<array> | ||
<string>group.com.synerise.sdk.sample-flutter</string> | ||
</array> | ||
<key>keychain-access-groups</key> | ||
<array> | ||
<string>$(AppIdentifierPrefix)FlutterKeychainGroup</string> | ||
</array> | ||
</dict> | ||
</plist> |
13 changes: 13 additions & 0 deletions
13
example/ios/SyneriseNotificationServiceExtension/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.usernotifications.service</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).NotificationService</string> | ||
</dict> | ||
</dict> | ||
</plist> |
74 changes: 74 additions & 0 deletions
74
example/ios/SyneriseNotificationServiceExtension/NotificationService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// NotificationService.swift | ||
// SyneriseNotificationServiceExtension | ||
// | ||
// Created by Krzysztof Kurzawa on 29/06/2023. | ||
// | ||
|
||
import UserNotifications | ||
import SyneriseSDK | ||
|
||
class NotificationService: UNNotificationServiceExtension, NotificationServiceExtensionDelegate, NotificationDelegate { | ||
|
||
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 = self.bestAttemptContent { | ||
Synerise.settings.sdk.appGroupIdentifier = "group.com.synerise.sdk.flutter" | ||
Synerise.settings.sdk.keychainGroupIdentifier = "34N2Z22TKH.FlutterKeychainGroup" | ||
|
||
NotificationServiceExtension.setDelegate(self) | ||
NotificationServiceExtension.setNotificationDelegate(self) | ||
|
||
#if DEBUG | ||
NotificationServiceExtension.setDebugModeEnabled(true) | ||
#endif | ||
|
||
// DEBUG ONLY !!! | ||
// Uncomment the 1 line below to cause service extension expiration and check how `serviceExtensionTimeWillExpire` method works. | ||
// Thread.sleep(forTimeInterval: 25) | ||
|
||
NotificationServiceExtension.setDecryptionFallbackNotificationTitleAndBody(title: "(Encrypted)", body: "(Encrypted)") | ||
NotificationServiceExtension.didReceiveNotificationExtensionRequest(request, withMutableNotificationContent: bestAttemptContent) | ||
|
||
// DEBUG ONLY !!! | ||
// Uncomment the 1 line below and comment out the one above to ensure this extension is executing. | ||
// Remember, this extension only runs when mutable-content is set true in Synerise campaign options. | ||
// bestAttemptContent.body = "[Modified]".appending(bestAttemptContent.body); | ||
contentHandler(bestAttemptContent) | ||
} | ||
} | ||
|
||
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 = self.contentHandler, let receivedRequest = self.receivedRequest, let bestAttemptContent = self.bestAttemptContent { | ||
NotificationServiceExtension.serviceExtensionTimeWillExpireRequest(receivedRequest, withMutableNotificationContent: bestAttemptContent) | ||
bestAttemptContent.title = "Fallback title" | ||
bestAttemptContent.body = "Fallback body" | ||
contentHandler(bestAttemptContent) | ||
} | ||
} | ||
|
||
func notificationServiceExtensionDidFailProcessingWithError(_ error: Error) { | ||
#if DEBUG | ||
self.bestAttemptContent?.title = error.localizedDescription | ||
#endif | ||
} | ||
|
||
func notificationServiceExtensionDidFailDecryptionWithError(_ error: Error) { | ||
#if DEBUG | ||
self.bestAttemptContent?.title = error.localizedDescription | ||
#endif | ||
} | ||
|
||
func snr_notificationDidReceive(notificationInfo: NotificationInfo) { | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...os/SyneriseNotificationServiceExtension/SyneriseNotificationServiceExtension.entitlements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.application-groups</key> | ||
<array> | ||
<string>group.com.synerise.sdk.sample-flutter</string> | ||
</array> | ||
<key>keychain-access-groups</key> | ||
<array> | ||
<string>$(AppIdentifierPrefix)FlutterKeychainGroup</string> | ||
</array> | ||
</dict> | ||
</plist> |
24 changes: 24 additions & 0 deletions
24
example/ios/SyneriseSingleMediaNotificationContentExtension/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionAttributes</key> | ||
<dict> | ||
<key>UNNotificationExtensionCategory</key> | ||
<array> | ||
<string>synerise.notifications.category.single-media</string> | ||
</array> | ||
<key>UNNotificationExtensionDefaultContentHidden</key> | ||
<true/> | ||
<key>UNNotificationExtensionInitialContentSizeRatio</key> | ||
<real>1</real> | ||
</dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.usernotifications.content-extension</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).NotificationViewController</string> | ||
</dict> | ||
</dict> | ||
</plist> |
31 changes: 31 additions & 0 deletions
31
example/ios/SyneriseSingleMediaNotificationContentExtension/NotificationViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// NotificationViewController.swift | ||
// SyneriseSingleMediaNotificationContentExtension | ||
// | ||
// Created by Krzysztof Kurzawa on 29/06/2023. | ||
// | ||
|
||
import UIKit | ||
import UserNotifications | ||
import UserNotificationsUI | ||
import SyneriseSDK | ||
|
||
class NotificationViewController: SingleMediaContentExtensionViewController, UNNotificationContentExtension { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
view.backgroundColor = UIColor.red | ||
} | ||
|
||
func didReceive(_ notification: UNNotification) { | ||
Synerise.settings.sdk.appGroupIdentifier = "group.com.synerise.sdk.flutter" | ||
Synerise.settings.sdk.keychainGroupIdentifier = "34N2Z22TKH.FlutterKeychainGroup" | ||
|
||
setSyneriseNotification(notification) | ||
} | ||
|
||
func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) { | ||
setSyneriseNotificationResponse(response, completionHandler: completion) | ||
} | ||
} |
Oops, something went wrong.