From ebb3b183a703136e44fc60ddd5847053669e52a3 Mon Sep 17 00:00:00 2001 From: Sergey Korney Date: Mon, 5 Aug 2024 20:25:45 +0500 Subject: [PATCH] 1.6.37 --- AffiseAttributionLib.podspec | 2 +- AffiseAttributionLib/Classes/Affise.swift | 8 --- .../Classes/internal/BuildConfig.swift | 2 +- .../Classes/internal/InternalAffise.swift | 34 +++++++++ .../RetrieveInstallReferrerUseCase.swift | 47 +++++++++---- AffiseInternal.podspec | 2 +- AffiseModule.podspec | 2 +- .../Classes/AdvertisingModule.swift | 2 +- AffiseModule/Link/Classes/LinkModule.swift | 2 +- .../Status/Classes/StatusModule.swift | 2 +- .../Classes/SubscriptionModule.swift | 2 +- AffiseSKAdNetwork.podspec | 2 +- CHANGELOG.md | 7 ++ README.md | 69 ++++++++++++------- example/app/app/AppDelegate.swift | 11 +++ 15 files changed, 141 insertions(+), 53 deletions(-) create mode 100644 AffiseAttributionLib/Classes/internal/InternalAffise.swift diff --git a/AffiseAttributionLib.podspec b/AffiseAttributionLib.podspec index 82e1f39..c0cf55d 100644 --- a/AffiseAttributionLib.podspec +++ b/AffiseAttributionLib.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |spec| spec.name = "AffiseAttributionLib" - spec.version = ENV['LIB_VERSION'] || "1.6.36" + spec.version = ENV['LIB_VERSION'] || "1.6.37" spec.summary = "Affise Attribution iOS library" spec.description = "Affise SDK is a software you can use to collect app usage statistics, device identifiers, deeplink usage, track install referrer." spec.homepage = "https://github.com/affise/sdk-ios" diff --git a/AffiseAttributionLib/Classes/Affise.swift b/AffiseAttributionLib/Classes/Affise.swift index 3079092..8e87b70 100644 --- a/AffiseAttributionLib/Classes/Affise.swift +++ b/AffiseAttributionLib/Classes/Affise.swift @@ -249,14 +249,6 @@ public final class Affise: NSObject { return api?.moduleManager.getModules() ?? [] } - /** - * Call deeplink handle manually - */ - @objc - public static func handleDeeplink(_ url: URL) { - api?.deeplinkManager.handleDeeplink(url: url) - } - internal static func getApi() -> AffiseApi? { return api } diff --git a/AffiseAttributionLib/Classes/internal/BuildConfig.swift b/AffiseAttributionLib/Classes/internal/BuildConfig.swift index 1608734..fda27e7 100644 --- a/AffiseAttributionLib/Classes/internal/BuildConfig.swift +++ b/AffiseAttributionLib/Classes/internal/BuildConfig.swift @@ -1,5 +1,5 @@ import Foundation internal struct BuildConfig { - static let AFFISE_VERSION = "1.6.36" + static let AFFISE_VERSION = "1.6.37" } diff --git a/AffiseAttributionLib/Classes/internal/InternalAffise.swift b/AffiseAttributionLib/Classes/internal/InternalAffise.swift new file mode 100644 index 0000000..018aa7b --- /dev/null +++ b/AffiseAttributionLib/Classes/internal/InternalAffise.swift @@ -0,0 +1,34 @@ +import Foundation + + +extension Affise { + + /** + * Call deeplink handle manually + */ + @objc + public static func handleDeeplink(_ url: URL?) { + Affise.getApi()?.deeplinkManager.handleDeeplink(url: url) + } + + /** + * Handle referrer manually + */ + @objc + public static func handleReferrer(_ url: URL?) { + Affise.getApi()?.retrieveInstallReferrerUseCase.setReferrer(url) + } + + /** + * Handle user activity deeplink and referrer manually + */ + @objc + public static func handleUserActivity(_ userActivity: NSUserActivity) { + if #available(iOS 11.0, *) { + Affise.handleReferrer(userActivity.referrerURL) + } + + // Get URL components from the incoming user activity. + Affise.handleDeeplink(userActivity.webpageURL) + } +} diff --git a/AffiseAttributionLib/Classes/referrer/RetrieveInstallReferrerUseCase.swift b/AffiseAttributionLib/Classes/referrer/RetrieveInstallReferrerUseCase.swift index 594668a..15a6649 100644 --- a/AffiseAttributionLib/Classes/referrer/RetrieveInstallReferrerUseCase.swift +++ b/AffiseAttributionLib/Classes/referrer/RetrieveInstallReferrerUseCase.swift @@ -2,8 +2,9 @@ import Foundation class RetrieveInstallReferrerUseCase { - let moduleManager: AffiseModuleManager - var referrerModule: ReferrerCallback? + private let moduleManager: AffiseModuleManager + private var referrerModule: ReferrerCallback? + private var referrerURL: URL? init( moduleManager: AffiseModuleManager @@ -11,7 +12,7 @@ class RetrieveInstallReferrerUseCase { self.moduleManager = moduleManager } - func getReffererModule() -> ReferrerCallback? { + private func getReffererModule() -> ReferrerCallback? { if self.referrerModule != nil { return self.referrerModule } @@ -21,22 +22,44 @@ class RetrieveInstallReferrerUseCase { return referrerModule } - func getQueryStringParameter(_ url: String, _ param: String) -> String? { + private func getQueryStringParameter(_ url: String?, _ param: String) -> String? { + guard let url = url else { + return nil + } guard let url = URLComponents(string: url) else { return nil } return url.queryItems?.first(where: { $0.name == param })?.value - } + } + + private func handleReferrer(_ callback: @escaping OnReferrerCallback) { + guard let referrer = referrerURL else { + getReffererModule()?.getReferrer(callback) ?? callback(nil) + return + } + callback(referrer.absoluteString) + } + /** + * Set referrerURL + */ + func setReferrer(_ url: URL?) { + referrerURL = url + } + + /** + * Return referrerURL + */ func getReferrer(_ callback: @escaping OnReferrerCallback) { - getReffererModule()?.getReferrer(callback) ?? callback(nil) + handleReferrer { value in + callback(value) + } } + /** + * Return referrerURL parameter by key + */ func getReferrerValue(_ key: ReferrerKey, _ callback: @escaping OnReferrerCallback) { - guard let module = getReffererModule() else { - callback(nil) - return - } - module.getReferrer { value in - callback(self.getQueryStringParameter("https://referrer/?\(value ?? "")", key.value())) + handleReferrer { value in + callback(self.getQueryStringParameter(value, key.value())) } } } diff --git a/AffiseInternal.podspec b/AffiseInternal.podspec index 27ac0dc..4745f61 100644 --- a/AffiseInternal.podspec +++ b/AffiseInternal.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |spec| spec.name = "AffiseInternal" - spec.version = ENV['LIB_VERSION'] || "1.6.36" + spec.version = ENV['LIB_VERSION'] || "1.6.37" spec.summary = "Affise Internal library" spec.description = "Affise Internal wrapper library for crossplatform" spec.homepage = "https://github.com/affise/sdk-ios" diff --git a/AffiseModule.podspec b/AffiseModule.podspec index 6b916d0..15fdd54 100644 --- a/AffiseModule.podspec +++ b/AffiseModule.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "AffiseModule" - s.version = ENV["LIB_VERSION"] || "1.6.36" + s.version = ENV["LIB_VERSION"] || "1.6.37" s.summary = "Affise Modules" s.description = "Affise module collection" s.homepage = "https://github.com/affise/sdk-ios" diff --git a/AffiseModule/Advertising/Classes/AdvertisingModule.swift b/AffiseModule/Advertising/Classes/AdvertisingModule.swift index 711fa74..2a76bea 100644 --- a/AffiseModule/Advertising/Classes/AdvertisingModule.swift +++ b/AffiseModule/Advertising/Classes/AdvertisingModule.swift @@ -4,7 +4,7 @@ import Foundation @objc(AffiseAdvertisingModule) public final class AdvertisingModule: AffiseModule { - public override var version: String { "1.6.36" } + public override var version: String { "1.6.37" } private lazy var advertisingIdManager: AdvertisingIdManager = AdvertisingIdManagerImpl() diff --git a/AffiseModule/Link/Classes/LinkModule.swift b/AffiseModule/Link/Classes/LinkModule.swift index 70f830e..ed77835 100644 --- a/AffiseModule/Link/Classes/LinkModule.swift +++ b/AffiseModule/Link/Classes/LinkModule.swift @@ -5,7 +5,7 @@ import AffiseAttributionLib @objc(AffiseLinkModule) public final class LinkModule: AffiseModule { - public override var version: String { "1.6.36" } + public override var version: String { "1.6.37" } private var useCase: LinkResolveUseCase? = nil diff --git a/AffiseModule/Status/Classes/StatusModule.swift b/AffiseModule/Status/Classes/StatusModule.swift index 6c66be3..28f0a34 100644 --- a/AffiseModule/Status/Classes/StatusModule.swift +++ b/AffiseModule/Status/Classes/StatusModule.swift @@ -5,7 +5,7 @@ import AffiseAttributionLib @objc(AffiseStatusModule) public final class StatusModule: AffiseModule { - public override var version: String { "1.6.36" } + public override var version: String { "1.6.37" } private var checkStatusUseCase: CheckStatusUseCase? = nil private var referrerUseCase: ReferrerUseCase? = nil diff --git a/AffiseModule/Subscription/Classes/SubscriptionModule.swift b/AffiseModule/Subscription/Classes/SubscriptionModule.swift index d5b755a..01c76dd 100644 --- a/AffiseModule/Subscription/Classes/SubscriptionModule.swift +++ b/AffiseModule/Subscription/Classes/SubscriptionModule.swift @@ -6,7 +6,7 @@ import AffiseAttributionLib @objc(AffiseSubscriptionModule) public final class SubscriptionModule: AffiseModule { - public override var version: String { "1.6.36" } + public override var version: String { "1.6.37" } lazy var storeManager: StoreManager = StoreManager() diff --git a/AffiseSKAdNetwork.podspec b/AffiseSKAdNetwork.podspec index bf4e2b2..9961845 100644 --- a/AffiseSKAdNetwork.podspec +++ b/AffiseSKAdNetwork.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |spec| spec.name = "AffiseSKAdNetwork" - spec.version = ENV['LIB_VERSION'] || "1.6.36" + spec.version = ENV['LIB_VERSION'] || "1.6.37" spec.summary = "AffiseSKAdNetwork iOS library" spec.description = "Affise library for StoreKit Ad Network (SKAdNetwork)" spec.homepage = "https://github.com/affise/sdk-ios" diff --git a/CHANGELOG.md b/CHANGELOG.md index b8a84f5..e9cd443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [1.6.37] - 2024-08-05 + +### Added + +- Add `NSUserActivity.referrerURL` for `Affise.getReferrer` and `Affise.getReferrerValue` + ## [1.6.36] - 2024-07-30 ### Fixed @@ -80,6 +86,7 @@ - Improve `AffiseModuleManager` - Update for demo app +[1.6.37]: https://github.com/affise/sdk-ios/compare/1.6.36...1.6.37 [1.6.36]: https://github.com/affise/sdk-ios/compare/1.6.35...1.6.36 [1.6.35]: https://github.com/affise/sdk-ios/compare/1.6.34...1.6.35 [1.6.34]: https://github.com/affise/sdk-ios/compare/1.6.33...1.6.34 diff --git a/README.md b/README.md index 8bae748..020093c 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ | Pod | Version | | ---- |:-------:| -| `AffiseAttributionLib` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/a/9/3/AffiseAttributionLib) | -| `AffiseSKAdNetwork` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/3/6/f/AffiseSKAdNetwork) | -| `AffiseModule/Advertising` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | -| `AffiseModule/Link` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | -| `AffiseModule/Status` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | +| `AffiseAttributionLib` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/a/9/3/AffiseAttributionLib) | +| `AffiseSKAdNetwork` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/3/6/f/AffiseSKAdNetwork) | +| `AffiseModule/Advertising` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | +| `AffiseModule/Link` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | +| `AffiseModule/Status` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | - [Affise Attribution iOS Library](#affise-attribution-ios-library) - [Description](#description) @@ -80,22 +80,22 @@ To add the SDK using Cocoapods, specify the version you want to use in your Podf ```ruby # Affise SDK library -pod 'AffiseAttributionLib', '~> 1.6.36' +pod 'AffiseAttributionLib', '~> 1.6.37' # Affise modules -pod 'AffiseModule/Advertising', '~> 1.6.36' -pod 'AffiseModule/Link', '~> 1.6.36' -pod 'AffiseModule/Status', '~> 1.6.36' +pod 'AffiseModule/Advertising', '~> 1.6.37' +pod 'AffiseModule/Link', '~> 1.6.37' +pod 'AffiseModule/Status', '~> 1.6.37' ``` Get source directly from GitHub ```ruby # Affise SDK library -pod 'AffiseAttributionLib', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.36' +pod 'AffiseAttributionLib', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.37' # Affise modules -pod 'AffiseModule/Advertising', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.36' -pod 'AffiseModule/Link', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.36' -pod 'AffiseModule/Status', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.36' +pod 'AffiseModule/Advertising', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.37' +pod 'AffiseModule/Link', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.37' +pod 'AffiseModule/Status', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.37' ``` ### Integrate as Swift Package Manager @@ -197,9 +197,9 @@ Affise | Module | Version | Start | | ------------- |:------------------------------------------------------------------------------------:|----------| -| `Advertising` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Manual` | -| `Link` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | -| `Status` | [`1.6.36`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | +| `Advertising` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Manual` | +| `Link` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | +| `Status` | [`1.6.37`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | If module start type is `manual`, then call: @@ -263,14 +263,14 @@ To add the SDK using Cocoapods, specify the version you want to use in your Podf ```ruby # Wrapper for StoreKit Ad Network -pod 'AffiseSKAdNetwork', '~> 1.6.36' +pod 'AffiseSKAdNetwork', '~> 1.6.37' ``` Get source directly from GitHub ```ruby # Wrapper for StoreKit Ad Network -pod 'AffiseSKAdNetwork', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.36' +pod 'AffiseSKAdNetwork', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.37' ``` For `swift` use: @@ -913,12 +913,7 @@ func application( continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void ) -> Bool { - // Get URL components from the incoming user activity. - guard url == userActivity.webpageURL else { - return false - } - - Affise.handleDeeplink(url) + Affise.handleUserActivity(userActivity) return true } ``` @@ -974,6 +969,19 @@ Affise.isFirstRun() > > Requires [Affise Status Module](#modules) +- Add referrer handler to `AppDelegate.swift` + +```swift +func application( + _ application: UIApplication, + continue userActivity: NSUserActivity, + restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void +) -> Bool { + Affise.handleUserActivity(userActivity) + return true +} +``` + Use the next public method of SDK ```swift @@ -988,6 +996,19 @@ Affise.getReferrer { referrer in > > Requires [Affise Status Module](#modules) +- Add referrer handler to `AppDelegate.swift` + +```swift +func application( + _ application: UIApplication, + continue userActivity: NSUserActivity, + restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void +) -> Bool { + Affise.handleUserActivity(userActivity) + return true +} +``` + Use the next public method of SDK to get referrer parameter by ```swift diff --git a/example/app/app/AppDelegate.swift b/example/app/app/AppDelegate.swift index af8218c..f68437d 100644 --- a/example/app/app/AppDelegate.swift +++ b/example/app/app/AppDelegate.swift @@ -68,10 +68,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate { open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:] ) -> Bool { + // Handle Deeplink Affise.handleDeeplink(url) return true } + func application( + _ application: UIApplication, + continue userActivity: NSUserActivity, + restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void + ) -> Bool { + // Handle AppLinks + Affise.handleUserActivity(userActivity) + return true + } + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.