Skip to content

Commit

Permalink
1.6.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Oct 24, 2023
1 parent ca162d2 commit e929d14
Show file tree
Hide file tree
Showing 20 changed files with 307 additions and 131 deletions.
2 changes: 1 addition & 1 deletion AffiseAttributionLib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
38 changes: 28 additions & 10 deletions AffiseAttributionLib/Classes/Affise.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// Affise.swift
//
// Created by Sergey Korney
//


/**
* Entry point to initialise Affise Attribution library
*/
Expand All @@ -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
Expand Down
7 changes: 0 additions & 7 deletions AffiseAttributionLib/Classes/AffiseApi.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// AffiseApi.swift
//
// Created by Sergey Korney
//


internal protocol AffiseApi {
var firstAppOpenUseCase: FirstAppOpenUseCase {get}
var sessionManager: SessionManager {get}
Expand Down
11 changes: 2 additions & 9 deletions AffiseAttributionLib/Classes/AffiseComponent.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// AffiseComponent.swift
// app
//
// Created by Sergey Korney
//


internal class AffiseComponent: AffiseApi {

private let app: UIApplication
Expand Down Expand Up @@ -38,7 +30,8 @@ internal class AffiseComponent: AffiseApi {
app: app,
dependencies: [
stringToSha256Converter,
networkService
networkService,
providersToJsonStringConverter
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
4 changes: 0 additions & 4 deletions AffiseAttributionLib/Classes/init/AffiseFlag.swift

This file was deleted.

22 changes: 10 additions & 12 deletions AffiseAttributionLib/Classes/init/AffiseInitProperties.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// AffiseInitProperties.swift
//
// Created by Sergey Korney
//


@objc
public class AffiseInitProperties: NSObject {
let affiseAppId: String?
Expand All @@ -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(
Expand All @@ -22,15 +15,18 @@ 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
self.partParamNameToken = partParamNameToken
self.appToken = appToken
self.isProduction = isProduction
self.secretKey = secretKey
self.flags = []
self.domain = domain

CloudConfig.setupDomain(domain)
}

@objc
Expand All @@ -44,7 +40,8 @@ public class AffiseInitProperties: NSObject {
partParamNameToken: nil,
appToken: nil,
isProduction: true,
secretKey: secretKey
secretKey: secretKey,
domain: nil
)
}

Expand All @@ -60,7 +57,8 @@ public class AffiseInitProperties: NSObject {
partParamNameToken: nil,
appToken: nil,
isProduction: isProduction,
secretKey: secretKey
secretKey: secretKey,
domain: nil
)
}
}
30 changes: 27 additions & 3 deletions AffiseAttributionLib/Classes/network/CloudConfig.swift
Original file line number Diff line number Diff line change
@@ -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<String> = [
"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)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class AffSDKVersionProvider: StringPropertyProvider {

override func provide() -> String? {
return "1.6.14"
return "1.6.15"
}

public override func getOrder() -> Float {
Expand Down
89 changes: 89 additions & 0 deletions AffiseAttributionLib/Classes/settings/AffiseSettings.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 1 addition & 1 deletion AffiseInternal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 15 additions & 2 deletions AffiseInternal/Classes/AffiseApiWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
27 changes: 0 additions & 27 deletions AffiseInternal/Classes/ext/AffiseInitPropertiesExt.swift

This file was deleted.

Loading

0 comments on commit e929d14

Please sign in to comment.