Skip to content

Commit

Permalink
1.6.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Nov 28, 2023
1 parent 5d78d56 commit e94a87d
Show file tree
Hide file tree
Showing 27 changed files with 185 additions and 75 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.16"
spec.version = ENV['LIB_VERSION'] || "1.6.17"
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
2 changes: 1 addition & 1 deletion AffiseAttributionLib/Classes/Affise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public final class Affise: NSObject {
* Register [callback] for deeplink
*/
@objc
public static func registerDeeplinkCallback(_ callback: @escaping (_ url: URL) -> Void) {
public static func registerDeeplinkCallback(_ callback: @escaping OnDeeplinkCallback) {
api?.deeplinkManager.setDeeplinkCallback(callback: callback)
}

Expand Down
4 changes: 3 additions & 1 deletion AffiseAttributionLib/Classes/AffiseComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ internal class AffiseComponent: AffiseApi {
lazy var stringToSha256Converter: StringToSHA256Converter = StringToSHA256Converter()
lazy var providersToJsonStringConverter: ProvidersToJsonStringConverter = ProvidersToJsonStringConverter()
lazy var deviceUseCase: DeviceUseCase = DeviceUseCaseImpl()
lazy var remarketingUseCase: RemarketingUseCase = RemarketingUseCaseImpl()

/**
* PostBackModelFactory
Expand All @@ -153,7 +154,8 @@ internal class AffiseComponent: AffiseApi {
stringToSha256Converter: stringToSha256Converter,
logsManager: logsManager,
deeplinkClickRepository: deeplinkClickRepository,
deviceUseCase: deviceUseCase
deviceUseCase: deviceUseCase,
remarketingUseCase: remarketingUseCase
).create()

lazy var moduleManager: AffiseModuleManager = AffiseModuleManager(
Expand Down
2 changes: 1 addition & 1 deletion AffiseAttributionLib/Classes/AffiseShared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class AffiseShared: NSObject {
* Register [callback] for deeplink
*/
@available(*, deprecated, message: "use Affise.registerDeeplinkCallback(_ callback:)")
public func registerDeeplinkCallback(callback: @escaping (_ url: URL) -> Void) {
public func registerDeeplinkCallback(callback: @escaping OnDeeplinkCallback) {
Affise.registerDeeplinkCallback(callback)
}

Expand Down
4 changes: 2 additions & 2 deletions AffiseAttributionLib/Classes/deeplink/DeeplinkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import UIKit
* Interface describing callback that is going to be triggered when deeplink is received by application
* Triggered when new deeplink [uri] is received by application with
*/
typealias OnDeeplinkCallback = (_ url: URL) -> Void
public typealias OnDeeplinkCallback = (_ url: URL?) -> Void

/**
* Manager that coordinates deeplink related tasks
Expand All @@ -24,5 +24,5 @@ protocol DeeplinkManager {
/**
* Process [uri] as deeplink
*/
func handleDeeplink(url: URL)
func handleDeeplink(url: URL?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ internal class DeeplinkManagerImpl : DeeplinkManager {
deeplinkCallback = callback
}

func handleDeeplink(url: URL) {
func handleDeeplink(url: URL?) {
isDeeplinkRepository.setDeeplinkClick(isDeeplink: true)
isDeeplinkRepository.setDeeplink(deeplink: url.absoluteString)
isDeeplinkRepository.setDeeplink(deeplink: url?.absoluteString ?? "")
deeplinkCallback?(url)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ public class InternalCrossPlatform {
private static func getApi() -> AffiseApi? { return Affise.getApi() }

public static func deeplink(_ uri: String) {
guard let url = URL(string: uri) else { return }

getApi()?.deeplinkManager.handleDeeplink(url: url)
getApi()?.deeplinkManager.handleDeeplink(url: URL(string: uri))
}

public static func start() {
Expand Down
14 changes: 12 additions & 2 deletions AffiseAttributionLib/Classes/parameters/ProviderType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ public enum ProviderType: Int {
case AFFISE_INTERNAL_EVENTS_COUNT
case IS_ROOTED
case IS_EMULATOR


// remarketing
case OS_AND_VERSION
case DEVICE
case BUILD

// advertising
case GAID_ADID
case GAID_ADID_MD5
Expand Down Expand Up @@ -187,7 +192,12 @@ public enum ProviderType: Int {
case .AFFISE_INTERNAL_EVENTS_COUNT: return "affise_internal_events_count"
case .IS_ROOTED: return "is_rooted"
case .IS_EMULATOR: return "is_emulator"


// remarketing
case .OS_AND_VERSION: return "os_and_version"
case .DEVICE: return "device"
case .BUILD: return "build"

// advertising
case .GAID_ADID: return "gaid_adid"
case .GAID_ADID_MD5: return "gaid_adid_md5"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

/**
* Provider for parameter [ProviderType.BUILD]
*/
class BuildProvider: StringPropertyProvider {

private let useCase: RemarketingUseCase

init(_ useCase: RemarketingUseCase) {
self.useCase = useCase
}

override func provide() -> String? {
useCase.build
}

public override func getOrder() -> Float {
70.0
}

public override func getKey() -> ProviderType? {
ProviderType.BUILD
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

/**
* Provider for parameter [ProviderType.DEVICE]
*/
class DeviceProvider: StringPropertyProvider {

private let useCase: RemarketingUseCase

init(_ useCase: RemarketingUseCase) {
self.useCase = useCase
}

override func provide() -> String? {
useCase.device
}

public override func getOrder() -> Float {
69.0
}

public override func getKey() -> ProviderType? {
ProviderType.DEVICE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ import Foundation
*/
class LanguageProvider: StringPropertyProvider {

private let useCase: RemarketingUseCase

init(_ useCase: RemarketingUseCase) {
self.useCase = useCase
}

override func provide() -> String? {
return Locale.current.identifier
useCase.local()
}

public override func getOrder() -> Float {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

/**
* Provider for parameter [ProviderType.OS_AND_VERSION]
*/
class OsAndVersionProvider: StringPropertyProvider {

private let useCase: RemarketingUseCase

init(_ useCase: RemarketingUseCase) {
self.useCase = useCase
}

override func provide() -> String? {
useCase.osAndVersion
}

public override func getOrder() -> Float {
68.0
}

public override func getKey() -> ProviderType? {
ProviderType.OS_AND_VERSION
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class PropertiesProviderFactory {
private let logsManager: LogsManager
private let deeplinkClickRepository: DeeplinkClickRepository
private let deviceUseCase: DeviceUseCase
private let remarketingUseCase: RemarketingUseCase

init(app: UIApplication,
bundle: Bundle,
Expand All @@ -32,7 +33,8 @@ internal class PropertiesProviderFactory {
stringToSha256Converter: StringToSHA256Converter,
logsManager: LogsManager,
deeplinkClickRepository: DeeplinkClickRepository,
deviceUseCase: DeviceUseCase
deviceUseCase: DeviceUseCase,
remarketingUseCase: RemarketingUseCase
) {
self.app = app
self.bundle = bundle
Expand All @@ -46,6 +48,7 @@ internal class PropertiesProviderFactory {
self.logsManager = logsManager
self.deeplinkClickRepository = deeplinkClickRepository
self.deviceUseCase = deviceUseCase
self.remarketingUseCase = remarketingUseCase
}

func create() -> PostBackModelFactory {
Expand Down Expand Up @@ -94,7 +97,7 @@ internal class PropertiesProviderFactory {
IsEmulatorProvider(useCase: deviceUseCase),
RegionProvider(),
CountryProvider(),
LanguageProvider(),
LanguageProvider(remarketingUseCase),
DeviceNameProvider(),
DeviceTypeProvider(),
OsNameProvider(),
Expand All @@ -117,7 +120,10 @@ internal class PropertiesProviderFactory {
AffAppTokenPropertyProvider(storage: initPropertiesStorage, stringToSHA256Converter: stringToSha256Converter),
// AffSDKSecretIdProvider(storage: initPropertiesStorage),
EmptyStringProvider(ProviderType.LABEL, order: 62.0),
PushTokenProvider(preferences: preferences)
PushTokenProvider(preferences: preferences),
OsAndVersionProvider(remarketingUseCase),
DeviceProvider(remarketingUseCase),
BuildProvider(remarketingUseCase)
]
)
}
Expand Down
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.16"
return "1.6.17"
}

public override func getOrder() -> Float {
Expand Down
8 changes: 0 additions & 8 deletions AffiseAttributionLib/Classes/usecase/PreferencesUseCase.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// PreferencesUseCase.swift
// AffiseAttributionLib
//
// Created by Sergey Korney
//


/**
* Use case to set library preferences
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// PreferencesUseCaseImpl.swift
// AffiseAttributionLib
//
// Created by Sergey Korney
//


/**
* Implementation of [PreferencesUseCase]
*
Expand Down
8 changes: 8 additions & 0 deletions AffiseAttributionLib/Classes/usecase/RemarketingUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
protocol RemarketingUseCase {

var osAndVersion: String { get }
var device: String? { get }
var build: String? { get }

func local() -> String
}
45 changes: 45 additions & 0 deletions AffiseAttributionLib/Classes/usecase/RemarketingUseCaseImpl.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Foundation
import UIKit

internal class RemarketingUseCaseImpl: RemarketingUseCase {

lazy var osAndVersion: String = getOsAndVersion()

lazy var device: String? = getDevice()

lazy var build: String? = getBuild()

func local() -> String {
let locale = Locale.current
guard let languageCode = locale.languageCode else { return locale.identifier }
guard let regionCode = locale.regionCode else { return locale.identifier }
return "\(languageCode)_\(regionCode)"
}

private func getOsAndVersion() -> String {
let uid:UIDevice = UIDevice.current
return "\(uid.systemName) \(uid.systemVersion)"
}

private func getDevice() -> String? {
return SysctlKey("hw.machine")
}

private func getBuild() -> String? {
if let build = SysctlKey("kern.osversion") {
return "Build/\(build)"
}
return nil
}

private func SysctlKey(_ key: String) -> String? {
var bufferSize = 0
sysctlbyname(key, nil, &bufferSize, nil, 0)
var buffer = [CChar](repeating: 0, count: Int(bufferSize))
let status = sysctlbyname(key, &buffer, &bufferSize, nil, 0)
if status != 0 {
return nil
}
return String(cString:buffer, encoding: String.Encoding.utf8)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// SendDataToServerUseCase.swift
// app
//
// Created by Sergey Korney
//


protocol SendDataToServerUseCase {

/**
Expand Down
8 changes: 0 additions & 8 deletions AffiseAttributionLib/Classes/usecase/StoreEventUseCase.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// StoreEventUseCase.swift
// app
//
// Created by Sergey Korney
//


/**
* Event use case for store events
*/
Expand Down
8 changes: 0 additions & 8 deletions AffiseAttributionLib/Classes/usecase/StoreLogsUseCase.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// StoreLogsUseCase.swift
// AffiseAttributionLib
//
// Created by Sergey Korney
//


/**
* UseCase store logs interface
*/
Expand Down
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.16"
spec.version = ENV['LIB_VERSION'] || "1.6.17"
spec.summary = "Affise Internal library"
spec.description = "Affise Internal wrapper library for crossplatform"
spec.homepage = "https://github.com/affise/sdk-ios"
Expand Down
2 changes: 1 addition & 1 deletion AffiseInternal/Classes/AffiseApiWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public class AffiseApiWrapper: NSObject {
Affise.registerDeeplinkCallback { uri in
let data: [String: Any?] = [
self.UUID: uuid,
api.method: uri.absoluteString,
api.method: uri?.absoluteString ?? "",
]
self.callback?(api.method, data)
}
Expand Down
Loading

0 comments on commit e94a87d

Please sign in to comment.