From 7520a0ae3689838f5ced3bba2781f9b0edaf4dd5 Mon Sep 17 00:00:00 2001 From: CataD256 Date: Tue, 22 Jun 2021 14:03:41 +0300 Subject: [PATCH 1/2] Update README.md (#12) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 29f3817..ca282fc 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,7 @@ An object that describes the contents of a shopping basket. * `currency`: (`String`, required) - A string representing the currency in ISO currency format. e.g. `"USD"`, `"GBP"` * `price`: (`float`, required) - A float value representing the pricing. * `items`: (`Array[OmetriaBasketItem]`) - An array containing the item entries in this basket. +* `link`: (`String`) - A deeplink to the web or in-app page for this basket. Can be used in a notification sent to the user, e.g. "Forgot to check out? Here's your basket to continue: ". Following that link should take them straight to the basket page. ### `OmetriaBasketItem` From d8fd61475c00b0e685769985625972e48f6cbae9 Mon Sep 17 00:00:00 2001 From: Cameron Cooke Date: Wed, 4 Aug 2021 16:13:09 +0100 Subject: [PATCH 2/2] Mark methods that use UIApplication as unavailable for non-app extensions (#13) This has been merged into xcode13-beta branch, which will be maintained up to date with new functionality until the official release of Xcode --- Sources/Ometria/ApplicationUtils.swift | 3 ++- .../Ometria/AutomaticLifecycleTracker.swift | 3 ++- Sources/Ometria/AutomaticPushTracker.swift | 24 ++++++++++++------- Sources/Ometria/Ometria.swift | 6 ++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Sources/Ometria/ApplicationUtils.swift b/Sources/Ometria/ApplicationUtils.swift index 908503f..01b219c 100644 --- a/Sources/Ometria/ApplicationUtils.swift +++ b/Sources/Ometria/ApplicationUtils.swift @@ -21,7 +21,8 @@ extension Ometria { } return sharedApplication } - + + @available(iOSApplicationExtension, unavailable) static func doesAppUseScenes() -> Bool { let delegateClass: AnyClass! = object_getClass(UIApplication.shared.delegate) diff --git a/Sources/Ometria/AutomaticLifecycleTracker.swift b/Sources/Ometria/AutomaticLifecycleTracker.swift index 5fc87e9..9bb4b8a 100644 --- a/Sources/Ometria/AutomaticLifecycleTracker.swift +++ b/Sources/Ometria/AutomaticLifecycleTracker.swift @@ -11,7 +11,8 @@ import UIKit open class AutomaticLifecycleTracker { var isRunning = false - + + @available(iOSApplicationExtension, unavailable) func startTracking() { guard !isRunning else { return diff --git a/Sources/Ometria/AutomaticPushTracker.swift b/Sources/Ometria/AutomaticPushTracker.swift index 3b8cec4..f426772 100644 --- a/Sources/Ometria/AutomaticPushTracker.swift +++ b/Sources/Ometria/AutomaticPushTracker.swift @@ -25,7 +25,8 @@ open class AutomaticPushTracker: NSObject { open var isRunning = false open var isDelegateObserverAdded = false - + + @available(iOSApplicationExtension, unavailable) open func startTracking() { guard !isRunning else { return @@ -39,7 +40,8 @@ open class AutomaticPushTracker: NSObject { NotificationCenter.default.addObserver(self, selector: #selector(firebaseTokenDidRefresh(notification:)), name: Notification.Name.MessagingRegistrationTokenRefreshed, object: nil) } - + + @available(iOSApplicationExtension, unavailable) open func stopTracking() { guard isRunning else { return @@ -59,7 +61,8 @@ open class AutomaticPushTracker: NSObject { UNUserNotificationCenter.current().removeDelegateObserver(observer: self) } } - + + @available(iOSApplicationExtension, unavailable) private func swizzleDidRegisterForRemoteNotificationsWithDeviceToken() { Logger.verbose(message: "Swizzle did register for remote notifications") let newSelector = #selector(UIResponder.om_application(_:didRegisterForRemoteNotificationsWithDeviceToken:)) @@ -73,13 +76,15 @@ open class AutomaticPushTracker: NSObject { Logger.verbose(message: "Application did register for remote notifications") } } - + + @available(iOSApplicationExtension, unavailable) private func unswizzleDidRegisterForRemoteNotificationsWithDeviceToken() { let delegateClass: AnyClass! = object_getClass(UIApplication.shared.delegate) let originalSelector = #selector(UIApplicationDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:)) Swizzler.unswizzleSelector(originalSelector, aClass: delegateClass) } - + + @available(iOSApplicationExtension, unavailable) private func swizzleDidFailToRegisterForRemoteNotificationsWithError() { Logger.verbose(message: "Swizzle did fail to register for remote notifications") let newSelector = #selector(UIResponder.om_application(_:didFailToRegisterForRemoteNotificationsWithError:)) @@ -93,14 +98,16 @@ open class AutomaticPushTracker: NSObject { Logger.verbose(message: "Application did fail to register for remote notifications") } } - + + @available(iOSApplicationExtension, unavailable) private func unswizzleDidFailToRegisterForRemoteNotificationsWithError() { let delegateClass: AnyClass! = object_getClass(UIApplication.shared.delegate) let originalSelector = #selector(UIApplicationDelegate.application(_:didFailToRegisterForRemoteNotificationsWithError:)) Swizzler.unswizzleSelector(originalSelector, aClass: delegateClass) } - + + @available(iOSApplicationExtension, unavailable) private func swizzleDidReceiveSilentNotification() { Logger.verbose(message: "Swizzle application:didReceiveRemoteNotification:fetchCompletionHandler:") let newSelector = #selector(UIResponder.om_application(_:didReceiveRemoteNotification:fetchCompletionHandler:)) @@ -114,7 +121,8 @@ open class AutomaticPushTracker: NSObject { Logger.debug(message: "Application didReceiveSilentNotification") } } - + + @available(iOSApplicationExtension, unavailable) private func unswizzleDidReceiveSilentNotification() { let delegateClass: AnyClass! = object_getClass(UIApplication.shared.delegate) let originalSelector = #selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)) diff --git a/Sources/Ometria/Ometria.swift b/Sources/Ometria/Ometria.swift index 52afec3..f5ea5a4 100644 --- a/Sources/Ometria/Ometria.swift +++ b/Sources/Ometria/Ometria.swift @@ -44,6 +44,7 @@ open class Ometria: NSObject, UNUserNotificationCenterDelegate { - Returns: returns an initialized Ometria instance object if needed to use or keep throughout the project. You can always get the initialized instance by calling sharedInstance() */ @discardableResult + @available(iOSApplicationExtension, unavailable) open class func initialize(apiToken: String) -> Ometria { let ometria = Ometria(apiToken: apiToken, config: OmetriaConfig()) instance = ometria @@ -62,7 +63,8 @@ open class Ometria: NSObject, UNUserNotificationCenterDelegate { } return instance! } - + + @available(iOSApplicationExtension, unavailable) init(apiToken: String, config: OmetriaConfig) { self.config = config self.apiToken = apiToken @@ -481,7 +483,9 @@ open class Ometria: NSObject, UNUserNotificationCenterDelegate { } // MARK: - Deeplink Interaction +@available(iOSApplicationExtension, unavailable) extension Ometria: OmetriaNotificationInteractionDelegate { + public func handleDeepLinkInteraction(_ deepLink: URL) { Logger.debug(message: "Open URL: \(deepLink)", category: .push) if Ometria.sharedUIApplication()?.canOpenURL(deepLink) == true {