From e929d14ab26494291717d5f710edefd818cefc7d Mon Sep 17 00:00:00 2001 From: Sergey Korney Date: Tue, 24 Oct 2023 17:53:27 +0500 Subject: [PATCH] 1.6.15 --- AffiseAttributionLib.podspec | 2 +- AffiseAttributionLib/Classes/Affise.swift | 38 +++++--- AffiseAttributionLib/Classes/AffiseApi.swift | 7 -- .../Classes/AffiseComponent.swift | 11 +-- .../validate/DebugValidateUseCaseImpl.swift | 7 +- .../Classes/init/AffiseFlag.swift | 4 - .../Classes/init/AffiseInitProperties.swift | 22 +++-- .../Classes/network/CloudConfig.swift | 30 ++++++- .../init/AffSDKVersionProvider.swift | 2 +- .../Classes/settings/AffiseSettings.swift | 89 +++++++++++++++++++ AffiseInternal.podspec | 2 +- AffiseInternal/Classes/AffiseApiWrapper.swift | 17 +++- .../Classes/ext/AffiseInitPropertiesExt.swift | 27 ------ .../Classes/ext/AffiseSettingsExt.swift | 64 +++++++++++++ AffiseModule.podspec | 2 +- .../usecase/CheckStatusUseCaseImpl.swift | 9 +- AffiseSKAdNetwork.podspec | 2 +- README.md | 71 +++++++++------ example/app-obj-c/app-obj-c/AppDelegate.m | 13 +-- example/app/app/AppDelegate.swift | 19 ++-- 20 files changed, 307 insertions(+), 131 deletions(-) delete mode 100644 AffiseAttributionLib/Classes/init/AffiseFlag.swift create mode 100644 AffiseAttributionLib/Classes/settings/AffiseSettings.swift delete mode 100644 AffiseInternal/Classes/ext/AffiseInitPropertiesExt.swift create mode 100644 AffiseInternal/Classes/ext/AffiseSettingsExt.swift diff --git a/AffiseAttributionLib.podspec b/AffiseAttributionLib.podspec index ff6896c..ba40ee2 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.14" + spec.version = ENV['LIB_VERSION'] || "1.6.15" 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 15f537a..80f314f 100644 --- a/AffiseAttributionLib/Classes/Affise.swift +++ b/AffiseAttributionLib/Classes/Affise.swift @@ -1,10 +1,3 @@ -// -// Affise.swift -// -// Created by Sergey Korney -// - - /** * Entry point to initialise Affise Attribution library */ @@ -22,19 +15,44 @@ public final class Affise: NSObject { * Api to communication with Affise */ private static var api: AffiseApi? + + /** + * Affise SDK settings builder + * To start SDK call .start(app:launchOptions:) + * [affiseAppId] - your app id + * [secretKey] - your SDK secretKey + */ + @objc + public static func settings( + affiseAppId: String, + secretKey: String + ) -> AffiseSettings { + return AffiseSettings(affiseAppId: affiseAppId, secretKey: secretKey) + } + + internal static func start( + initProperties: AffiseInitProperties, + app: UIApplication, + launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) { + if (api == nil) { + api = AffiseComponent(app: app, initProperties: initProperties, launchOptions: launchOptions) + } else { + debugPrint("Affise SDK is already initialized") + } + } /** * Init [AffiseComponent] with [app] and [initProperties] */ @objc + @available(*, deprecated, message: "use Affise.settings(affiseAppId:secretKey:).start(app:launchOptions:)") public static func load( app: UIApplication, initProperties: AffiseInitProperties, launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) { - if (api == nil) { - api = AffiseComponent(app: app, initProperties: initProperties, launchOptions: launchOptions) - } + start(initProperties: initProperties, app: app, launchOptions: launchOptions) } @objc diff --git a/AffiseAttributionLib/Classes/AffiseApi.swift b/AffiseAttributionLib/Classes/AffiseApi.swift index dfe4a80..5d4d7bc 100644 --- a/AffiseAttributionLib/Classes/AffiseApi.swift +++ b/AffiseAttributionLib/Classes/AffiseApi.swift @@ -1,10 +1,3 @@ -// -// AffiseApi.swift -// -// Created by Sergey Korney -// - - internal protocol AffiseApi { var firstAppOpenUseCase: FirstAppOpenUseCase {get} var sessionManager: SessionManager {get} diff --git a/AffiseAttributionLib/Classes/AffiseComponent.swift b/AffiseAttributionLib/Classes/AffiseComponent.swift index 5586d9a..b6a6793 100644 --- a/AffiseAttributionLib/Classes/AffiseComponent.swift +++ b/AffiseAttributionLib/Classes/AffiseComponent.swift @@ -1,11 +1,3 @@ -// -// AffiseComponent.swift -// app -// -// Created by Sergey Korney -// - - internal class AffiseComponent: AffiseApi { private let app: UIApplication @@ -38,7 +30,8 @@ internal class AffiseComponent: AffiseApi { app: app, dependencies: [ stringToSha256Converter, - networkService + networkService, + providersToJsonStringConverter ] ) diff --git a/AffiseAttributionLib/Classes/debug/validate/DebugValidateUseCaseImpl.swift b/AffiseAttributionLib/Classes/debug/validate/DebugValidateUseCaseImpl.swift index b87c47b..e2af3d8 100644 --- a/AffiseAttributionLib/Classes/debug/validate/DebugValidateUseCaseImpl.swift +++ b/AffiseAttributionLib/Classes/debug/validate/DebugValidateUseCaseImpl.swift @@ -9,7 +9,8 @@ class DebugValidateUseCaseImpl { let INVALID_CHECK_SUM = "Failed to get application or check sum" let PACKAGE_NAME_NOT_FOUND = "Package name not found" - let URL = "https://tracking.affattr.com/postback/validate" + let PATH = "postback/validate" + var url: String = "" let initProperties: AffiseInitProperties let logsManager: LogsManager @@ -30,10 +31,12 @@ class DebugValidateUseCaseImpl { self.converter = converter self.providers = postBackModelFactory.getRequestProviders() + + self.url = CloudConfig.getURL(PATH) } private func createRequest() -> HttpResponse { - guard let httpsUrl = URL.toURL() else { return HttpResponse(0, "", nil) } + guard let httpsUrl = url.toURL() else { return HttpResponse(0, "", nil) } //Create request return networkService.executeRequest( diff --git a/AffiseAttributionLib/Classes/init/AffiseFlag.swift b/AffiseAttributionLib/Classes/init/AffiseFlag.swift deleted file mode 100644 index 95dcfbd..0000000 --- a/AffiseAttributionLib/Classes/init/AffiseFlag.swift +++ /dev/null @@ -1,4 +0,0 @@ -@objc -public enum AffiseFlag: Int { - case IOS_REQUEST_ADID -} diff --git a/AffiseAttributionLib/Classes/init/AffiseInitProperties.swift b/AffiseAttributionLib/Classes/init/AffiseInitProperties.swift index 7565069..3bcfc00 100644 --- a/AffiseAttributionLib/Classes/init/AffiseInitProperties.swift +++ b/AffiseAttributionLib/Classes/init/AffiseInitProperties.swift @@ -1,10 +1,3 @@ -// -// AffiseInitProperties.swift -// -// Created by Sergey Korney -// - - @objc public class AffiseInitProperties: NSObject { let affiseAppId: String? @@ -13,7 +6,7 @@ public class AffiseInitProperties: NSObject { let appToken: String? let isProduction: Bool let secretKey: String? - let flags: [AffiseFlag] + let domain: String? @objc public init( @@ -22,7 +15,8 @@ public class AffiseInitProperties: NSObject { partParamNameToken: String? = nil, appToken: String? = nil, isProduction: Bool = true, - secretKey: String? = nil + secretKey: String? = nil, + domain: String? = nil ) { self.affiseAppId = affiseAppId self.partParamName = partParamName @@ -30,7 +24,9 @@ public class AffiseInitProperties: NSObject { self.appToken = appToken self.isProduction = isProduction self.secretKey = secretKey - self.flags = [] + self.domain = domain + + CloudConfig.setupDomain(domain) } @objc @@ -44,7 +40,8 @@ public class AffiseInitProperties: NSObject { partParamNameToken: nil, appToken: nil, isProduction: true, - secretKey: secretKey + secretKey: secretKey, + domain: nil ) } @@ -60,7 +57,8 @@ public class AffiseInitProperties: NSObject { partParamNameToken: nil, appToken: nil, isProduction: isProduction, - secretKey: secretKey + secretKey: secretKey, + domain: nil ) } } diff --git a/AffiseAttributionLib/Classes/network/CloudConfig.swift b/AffiseAttributionLib/Classes/network/CloudConfig.swift index cf5101c..eef150d 100644 --- a/AffiseAttributionLib/Classes/network/CloudConfig.swift +++ b/AffiseAttributionLib/Classes/network/CloudConfig.swift @@ -1,13 +1,37 @@ public struct CloudConfig { + static internal let defaultDomain: String = "https://tracking.affattr.com/" + static private let path: String = "postback" + + static private var domain: String = defaultDomain + /** * Urls for send data */ - static let urls: Array = [ - "https://tracking.affattr.com/postback" + static public private(set) var urls: [String] = [ + "\(domain)\(path)" ] - public static let headers: [String:String] = [ + static public let headers: [String:String] = [ "Content-Type" : "application/json; charset=utf-8" ] + + static internal func setupDomain(_ domain: String?) { + guard let domain = domain else { return } + if domain.isEmpty { return } + + if domain.hasSuffix("/") { + self.domain = domain + } else { + self.domain = "\(domain)/" + } + + self.urls = [ + getURL(path) + ] + } + + static public func getURL(_ path: String) -> String { + return "\(domain)\(path)" + } } diff --git a/AffiseAttributionLib/Classes/parameters/providers/init/AffSDKVersionProvider.swift b/AffiseAttributionLib/Classes/parameters/providers/init/AffSDKVersionProvider.swift index ccef41f..8ea43b4 100644 --- a/AffiseAttributionLib/Classes/parameters/providers/init/AffSDKVersionProvider.swift +++ b/AffiseAttributionLib/Classes/parameters/providers/init/AffSDKVersionProvider.swift @@ -5,7 +5,7 @@ class AffSDKVersionProvider: StringPropertyProvider { override func provide() -> String? { - return "1.6.14" + return "1.6.15" } public override func getOrder() -> Float { diff --git a/AffiseAttributionLib/Classes/settings/AffiseSettings.swift b/AffiseAttributionLib/Classes/settings/AffiseSettings.swift new file mode 100644 index 0000000..d7154ed --- /dev/null +++ b/AffiseAttributionLib/Classes/settings/AffiseSettings.swift @@ -0,0 +1,89 @@ +@objc +public class AffiseSettings: NSObject { + + private let affiseAppId: String? + private let secretKey: String? + private var isProduction: Bool = true + private var partParamName: String? + private var partParamNameToken: String? + private var appToken: String? + private var domain: String? + + @objc + internal init( + affiseAppId: String, + secretKey: String + ) { + self.affiseAppId = affiseAppId + self.secretKey = secretKey + } + + /** + * Set Affise SDK for SandBox / Production + */ + @objc + public func setProduction(_ production: Bool) -> AffiseSettings { + self.isProduction = production + return self + } + + /** + * Only for specific use case [partParamName] + */ + @objc + public func setPartParamName(_ partParamName: String) -> AffiseSettings { + self.partParamName = partParamName + return self + } + + /** + * Only for specific use case [partParamNameToken] + */ + @objc + public func setPartParamNameToken(_ partParamNameToken: String) -> AffiseSettings { + self.partParamNameToken = partParamNameToken + return self + } + + /** + * Set [appToken] + */ + @objc + public func setAppToken(_ appToken: String) -> AffiseSettings { + self.appToken = appToken + return self + } + + /** + * Set Affise SDK server [domain] + * Triling slash is irrelivant + */ + @objc + public func setDomain(_ domain: String) -> AffiseSettings { + self.domain = domain + return self + } + + private func getInitProperties() -> AffiseInitProperties { + return AffiseInitProperties( + affiseAppId: affiseAppId, + partParamName: partParamName, + partParamNameToken: partParamNameToken, + appToken: appToken, + isProduction: isProduction, + secretKey: secretKey, + domain: domain + ) + } + + /** + * Start Affise SDK using [app] and [launchOptions] + */ + @objc + public func start( + app: UIApplication, + launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) { + Affise.start(initProperties: getInitProperties(), app: app, launchOptions: launchOptions) + } +} diff --git a/AffiseInternal.podspec b/AffiseInternal.podspec index 36e7281..e97d868 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.14" + spec.version = ENV['LIB_VERSION'] || "1.6.15" spec.summary = "Affise Internal library" spec.description = "Affise Internal wrapper library for crossplatform" spec.homepage = "https://github.com/affise/sdk-ios" diff --git a/AffiseInternal/Classes/AffiseApiWrapper.swift b/AffiseInternal/Classes/AffiseApiWrapper.swift index e30705e..4eea051 100644 --- a/AffiseInternal/Classes/AffiseApiWrapper.swift +++ b/AffiseInternal/Classes/AffiseApiWrapper.swift @@ -109,8 +109,21 @@ public class AffiseApiWrapper: NSObject { result?.error("api [\(api.method)]: value not set") return } - - Affise.load(app: app, initProperties: data.toAffiseInitProperties, launchOptions: launchOptions) + + if !data.isValid() { + result?.error("api [\(api.method)]: affiseAppId or secretKey is not set") + return + } + + let (affiseAppId, secretKey) = data.getAppIdAndSecretKey() + + Affise + .settings( + affiseAppId: affiseAppId, + secretKey: secretKey + ) + .addSettings(data) + .start(app: app, launchOptions: launchOptions) result?.success(nil) } diff --git a/AffiseInternal/Classes/ext/AffiseInitPropertiesExt.swift b/AffiseInternal/Classes/ext/AffiseInitPropertiesExt.swift deleted file mode 100644 index 26c9a1d..0000000 --- a/AffiseInternal/Classes/ext/AffiseInitPropertiesExt.swift +++ /dev/null @@ -1,27 +0,0 @@ -import AffiseAttributionLib - -internal extension Dictionary where Key == String, Value == Any? { - class Keys { - static let FIELD_AFFISE_APP_ID = "affiseAppId" - static let FIELD_PART_PARAM_NAME = "partParamName" - static let FIELD_PART_PARAM_NAME_TOKEN = "partParamNameToken" - static let FIELD_APP_TOKEN = "appToken" - static let FIELD_SECRET_ID = "secretId" - // static let FIELD_AUTO_CATCHING_CLICK_EVENTS = "autoCatchingClickEvents" - static let FIELD_IS_PRODUCTION = "isProduction" - // static let FIELD_ENABLED_METRICS = "enabledMetrics" - } - - var toAffiseInitProperties: AffiseInitProperties { - let map = self - - return AffiseInitProperties( - affiseAppId: map[Keys.FIELD_AFFISE_APP_ID] as? String, - partParamName: map[Keys.FIELD_PART_PARAM_NAME] as? String, - partParamNameToken: map[Keys.FIELD_PART_PARAM_NAME_TOKEN] as? String, - appToken: map[Keys.FIELD_APP_TOKEN] as? String, - isProduction: map[Keys.FIELD_IS_PRODUCTION] as? Bool ?? false, - secretKey: map[Keys.FIELD_SECRET_ID] as? String - ) - } -} diff --git a/AffiseInternal/Classes/ext/AffiseSettingsExt.swift b/AffiseInternal/Classes/ext/AffiseSettingsExt.swift new file mode 100644 index 0000000..2505ec2 --- /dev/null +++ b/AffiseInternal/Classes/ext/AffiseSettingsExt.swift @@ -0,0 +1,64 @@ +import AffiseAttributionLib + + +internal class Field { + static let AFFISE_APP_ID = "affiseAppId" + static let SECRET_KEY = "secretKey" + static let PART_PARAM_NAME = "partParamName" + static let PART_PARAM_NAME_TOKEN = "partParamNameToken" + static let APP_TOKEN = "appToken" + // static let AUTO_CATCHING_CLICK_EVENTS = "autoCatchingClickEvents" + static let IS_PRODUCTION = "isProduction" + // static let ENABLED_METRICS = "enabledMetrics" + static let DOMAIN = "domain" +} + +internal extension Dictionary where Key == String, Value == Any? { + + func getString(_ key: String) -> String? { + return self[key] as? String + } + + func getBool(_ key: String) -> Bool? { + return self[key] as? Bool + } + + func isValid() -> Bool { + guard let affiseAppId = self.getString(Field.AFFISE_APP_ID) else { return false } + if affiseAppId.isEmpty { return false } + guard let secretKey = self.getString(Field.SECRET_KEY) else { return false } + if secretKey.isEmpty { return false } + + return true + } + + func getAppIdAndSecretKey() -> (String, String) { + return (self.getString(Field.AFFISE_APP_ID) ?? "", self.getString(Field.SECRET_KEY) ?? "") + } +} + +internal extension AffiseSettings { + func addSettings(_ data: [String: Any?]) -> AffiseSettings { + if let value = data.getString(Field.DOMAIN) { + self.setDomain(value) + } + + if let value = data.getBool(Field.IS_PRODUCTION) { + self.setProduction(value) + } + + if let value = data.getString(Field.PART_PARAM_NAME) { + self.setPartParamName(value) + } + + if let value = data.getString(Field.PART_PARAM_NAME_TOKEN) { + self.setPartParamNameToken(value) + } + + if let value = data.getString(Field.APP_TOKEN) { + self.setAppToken(value) + } + + return self + } +} diff --git a/AffiseModule.podspec b/AffiseModule.podspec index 75a5f51..6744d4a 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.14" + s.version = ENV["LIB_VERSION"] || "1.6.15" s.summary = "Affise Modules" s.description = "Affise module collection" s.homepage = "https://github.com/affise/sdk-ios" diff --git a/AffiseModule/Status/Classes/usecase/CheckStatusUseCaseImpl.swift b/AffiseModule/Status/Classes/usecase/CheckStatusUseCaseImpl.swift index 928d635..80ede39 100644 --- a/AffiseModule/Status/Classes/usecase/CheckStatusUseCaseImpl.swift +++ b/AffiseModule/Status/Classes/usecase/CheckStatusUseCaseImpl.swift @@ -6,7 +6,8 @@ internal class CheckStatusUseCaseImpl { private let ATTEMPTS_TO_SEND = 30 private let TIMEOUT_SEND: TimeInterval = 30 - let URL = "https://tracking.affattr.com/check_status" + let PATH: String = "check_status" + var url: String = "" let logsManager: LogsManager let converter: ProvidersToJsonStringConverter @@ -26,10 +27,12 @@ internal class CheckStatusUseCaseImpl { self.keyValueConverter = keyValueConverter self.networkService = networkService self.providers = affiseModule.getRequestProviders() + + self.url = CloudConfig.getURL(PATH) } private func createRequest() -> HttpResponse { - guard let httpsUrl = URL.toURL() else { return HttpResponse(0, "", nil) } + guard let httpsUrl = url.toURL() else { return HttpResponse(0, "", nil) } //Create request return networkService.executeRequest( @@ -74,7 +77,7 @@ extension CheckStatusUseCaseImpl: CheckStatusUseCase { onComplete([]) let error = AffiseError.network(status: response.code, message: response.body) //Log error - logsManager.addSdkError(error: AffiseError.cloud(url: URL, error: error, attempts: ATTEMPTS_TO_SEND, retry: true)) + logsManager.addSdkError(error: AffiseError.cloud(url: url, error: error, attempts: ATTEMPTS_TO_SEND, retry: true)) } else { onFailedAttempt() } diff --git a/AffiseSKAdNetwork.podspec b/AffiseSKAdNetwork.podspec index 893428e..1e6cdc1 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.14" + spec.version = ENV['LIB_VERSION'] || "1.6.15" 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/README.md b/README.md index 04b6724..1e59be8 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ | Pod | Version | | ---- |:-------:| -| `AffiseAttributionLib` | [`1.6.14`](https://github.com/CocoaPods/Specs/tree/master/Specs/a/9/3/AffiseAttributionLib) | -| `AffiseSKAdNetwork` | [`1.6.14`](https://github.com/CocoaPods/Specs/tree/master/Specs/3/6/f/AffiseSKAdNetwork) | -| `AffiseModule/Status` | [`1.6.14`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | +| `AffiseAttributionLib` | [`1.6.15`](https://github.com/CocoaPods/Specs/tree/master/Specs/a/9/3/AffiseAttributionLib) | +| `AffiseSKAdNetwork` | [`1.6.15`](https://github.com/CocoaPods/Specs/tree/master/Specs/3/6/f/AffiseSKAdNetwork) | +| `AffiseModule/Status` | [`1.6.15`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | - [Affise Attribution iOS Library](#affise-attribution-ios-library) - [Description](#description) @@ -12,6 +12,7 @@ - [Integration](#integration) - [Integrate as Cocoapods](#integrate-as-cocoapods) - [Initialize](#initialize) + - [Domain](#domain) - [Requirements](#requirements) - [StoreKit Ad Network](#storekit-ad-network) - [Features](#features) @@ -65,18 +66,18 @@ To add the SDK using Cocoapods, specify the version you want to use in your Podf ```ruby # Affise SDK library -pod 'AffiseAttributionLib', '~> 1.6.14' +pod 'AffiseAttributionLib', '~> 1.6.15' # Affise module -pod 'AffiseModule/Status', '~> 1.6.14' +pod 'AffiseModule/Status', '~> 1.6.15' ``` Get source directly from GitHub ```ruby # Affise SDK library -pod 'AffiseAttributionLib', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.14' +pod 'AffiseAttributionLib', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.15' # Affise module -pod 'AffiseModule/Status', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.14' +pod 'AffiseModule/Status', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.15' ``` ### Initialize @@ -97,11 +98,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. - let properties = AffiseInitProperties( - affiseAppId: "Your appId", //Change to your app id - secretKey: "Your secretKey" //Change to your appToken - ) - Affise.load(app: application, initProperties: properties, launchOptions: launchOptions) + Affise + .settings( + affiseAppId: "Your appId", //Change to your app id + secretKey: "Your secretKey" //Change to your appToken + ) + .start(app: application, launchOptions: launchOptions) // Start Affise SDK return true } @@ -122,12 +124,11 @@ For `objective-c` use: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. - AffiseInitProperties *initProperties = [[AffiseInitProperties alloc] - initWithAffiseAppId:@"Your appId" //Change to your app id - secretKey:@"Your secretKey" //Change to your appToken + AffiseSettings *affise = [Affise settingsWithAffiseAppId:@"Your appId" //Change to your app id + secretKey:@"Your secretKey" //Change to your appToken ]; - - [Affise loadWithApp:application initProperties:initProperties launchOptions:launchOptions]; + [affise setProduction:false]; //To enable debug methods set Production to false + [affise startWithApp:application launchOptions:launchOptions]; // Start Affise SDK return YES; } @@ -140,6 +141,20 @@ Check if library is initialized Affise.isInitialized() ``` +#### Domain + +Set SDK server doamin: + +```swift +Affise + .settings( + affiseAppId: "Your appId", + secretKey: "Your secretKey" + ) + .setDomain("https://YourCustomDomain") // Set custom domain + .start(app: application, launchOptions: launchOptions) +``` + ### Requirements Affise SDK uses `AppTrackingTransparency` framework to get `advertisingIdentifier` @@ -162,14 +177,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.14' +pod 'AffiseSKAdNetwork', '~> 1.6.15' ``` Get source directly from GitHub ```ruby # Wrapper for StoreKit Ad Network -pod 'AffiseSKAdNetwork', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.14' +pod 'AffiseSKAdNetwork', :git => 'https://github.com/affise/sdk-ios.git', :tag => '1.6.15' ``` For `swift` use: @@ -651,10 +666,10 @@ Affise.addPushToken(token) To integrate deeplink support You can find out how to set up deeplinks in the [official documentation](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app). -Register deeplink callback right after `Affise.init(..)` +Register deeplink callback right after `Affise.settings(..).start(..)` ```swift -Affise.init(..) +Affise.settings(affiseAppId:affiseAppId, secretKey:secretKey).start(app:app, launchOptions: launchOptions) Affise.registerDeeplinkCallback { url in let component = URLComponents(string: url.absoluteString)! let screen = component.queryItems?.first(where: {$0.name == ""})?.value @@ -1031,15 +1046,13 @@ Validate your credentials by receiving `ValidationStatus` values: - `NETWORK_ERROR` - network or server not available (for example `Airoplane mode` is active) ```swift -Affise.load(app: application, - initProperties: AffiseInitProperties( +Affise + .settings( affiseAppId: "Your appId", - secretKey: "Your secretKey", - isProduction: false, //To enable debug methods set Production to false - ), - launchOptions: launchOptions -) - + secretKey: "Your secretKey" + ) + .setProduction(false) //To enable debug methods set Production to false + .start(app: application, launchOptions: launchOptions) // Start Affise SDK Affise.Debug.validate { status in // Handle validation status diff --git a/example/app-obj-c/app-obj-c/AppDelegate.m b/example/app-obj-c/app-obj-c/AppDelegate.m index 7cdbfd5..aed8524 100644 --- a/example/app-obj-c/app-obj-c/AppDelegate.m +++ b/example/app-obj-c/app-obj-c/AppDelegate.m @@ -15,15 +15,10 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. - AffiseInitProperties *initProperties = [[AffiseInitProperties alloc] initWithAffiseAppId:@"129" - partParamName:nil - partParamNameToken:nil - appToken:nil - isProduction:NO - secretKey:@"93a40b54-6f12-443f-a250-ebf67c5ee4d2"]; - - [Affise loadWithApp:application initProperties:initProperties launchOptions:launchOptions]; - + AffiseSettings *affise = [Affise settingsWithAffiseAppId:@"129" secretKey:@"93a40b54-6f12-443f-a250-ebf67c5ee4d2"]; + [affise setProduction:false]; //To enable debug methods set Production to false + [affise startWithApp:application launchOptions:launchOptions]; // Start Affise SDK + // if (@available(iOS 16.1, *)) { // } else { // [AffiseSKAd registerWithCompletionHandler:^(NSString * error) { diff --git a/example/app/app/AppDelegate.swift b/example/app/app/AppDelegate.swift index fa194aa..b864b31 100644 --- a/example/app/app/AppDelegate.swift +++ b/example/app/app/AppDelegate.swift @@ -12,12 +12,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Override point for customization after application launch. // Initialize https://github.com/affise/sdk-ios#initialize - let properties = AffiseInitProperties( - affiseAppId: "129", - secretKey: "93a40b54-6f12-443f-a250-ebf67c5ee4d2", - isProduction: false //To enable debug methods set Production to false - ) - Affise.load(app: application, initProperties: properties, launchOptions: launchOptions) + Affise + .settings( + affiseAppId: "129", + secretKey: "93a40b54-6f12-443f-a250-ebf67c5ee4d2" + ) + .setProduction(false) //To enable debug methods set Production to false + .start(app: application, launchOptions: launchOptions) // Start Affise SDK // Deeplinks https://github.com/affise/sdk-ios#deeplinks Affise.registerDeeplinkCallback { url in @@ -44,9 +45,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // } // Debug: Validate credentials https://github.com/affise/sdk-ios#validate-credentials - Affise.Debug.validate { status in - debugPrint("Affise: validate = \(status)") - } +// Affise.Debug.validate { status in +// debugPrint("Affise: validate = \(status)") +// } // Debug: network request/response Affise.Debug.network { (request, response) in