Skip to content

Commit

Permalink
Merge branch 'xcode13-beta' into release/v1.2.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	Sources/Ometria/Ometria.swift
  • Loading branch information
Catalin Demian committed Oct 12, 2021
2 parents 7c93b6b + fd31200 commit f3f62e2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
3 changes: 2 additions & 1 deletion Sources/Ometria/ApplicationUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ extension Ometria {
}
return sharedApplication
}


@available(iOSApplicationExtension, unavailable)
static func doesAppUseScenes() -> Bool {
let delegateClass: AnyClass! = object_getClass(UIApplication.shared.delegate)

Expand Down
3 changes: 2 additions & 1 deletion Sources/Ometria/AutomaticLifecycleTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import UIKit
open class AutomaticLifecycleTracker {

var isRunning = false


@available(iOSApplicationExtension, unavailable)
func startTracking() {
guard !isRunning else {
return
Expand Down
24 changes: 16 additions & 8 deletions Sources/Ometria/AutomaticPushTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +44,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
Expand All @@ -63,7 +65,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:))
Expand All @@ -77,13 +80,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:))
Expand All @@ -97,14 +102,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:))
Expand All @@ -118,7 +125,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:))
Expand Down
8 changes: 6 additions & 2 deletions Sources/Ometria/Ometria.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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
Expand All @@ -61,7 +62,8 @@ open class Ometria: NSObject, UNUserNotificationCenterDelegate {
}
return instance!
}


@available(iOSApplicationExtension, unavailable)
init(apiToken: String, config: OmetriaConfig) {
self.config = config
self.apiToken = apiToken
Expand Down Expand Up @@ -505,6 +507,8 @@ open class Ometria: NSObject, UNUserNotificationCenterDelegate {
}

// MARK: - Deeplink Interaction

@available(iOSApplicationExtension, unavailable)
extension Ometria: OmetriaNotificationInteractionDelegate {

public func handleOmetriaNotificationInteraction(_ notification: OmetriaNotification) {
Expand All @@ -513,7 +517,7 @@ extension Ometria: OmetriaNotificationInteractionDelegate {
}

if Ometria.sharedUIApplication()?.canOpenURL(url) == true {
Logger.debug(message: "Open URL: \(notification.deepLinkActionUrl)", category: .push)
Logger.debug(message: "Open URL: \(urlString)", category: .push)
Ometria.sharedUIApplication()?.open(url)
trackDeepLinkOpenedEvent(link: url.absoluteString, screenName: "Safari")
}
Expand Down

0 comments on commit f3f62e2

Please sign in to comment.