Skip to content

Commit

Permalink
1.6.18
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Dec 7, 2023
1 parent e94a87d commit 3737b01
Show file tree
Hide file tree
Showing 26 changed files with 205 additions and 68 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/cocoapods_token.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CocoaPods Token
on:
schedule:
- cron: "0 0 * * 0"

jobs:
pods:
name: pod
runs-on: macOS-latest

steps:
- name: Pod trunk me
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk me
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.17"
spec.version = ENV['LIB_VERSION'] || "1.6.18"
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
8 changes: 8 additions & 0 deletions AffiseAttributionLib/Classes/Affise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ public final class Affise: NSObject {
api?.moduleManager.status(module, onComplete)
}

/**
* Manual module start
*/
@objc
public static func moduleStart(_ module: AffiseModules) {
api?.moduleManager.manualStart(module)
}

/**
* Call deeplink handle manually
*/
Expand Down
11 changes: 5 additions & 6 deletions AffiseAttributionLib/Classes/AffiseComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ internal class AffiseComponent: AffiseApi {
private let launchOptions: [UIApplication.LaunchOptionsKey: Any]?
private var isReady: Bool = false

init(app: UIApplication,
initProperties: AffiseInitProperties,
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
init(
app: UIApplication,
initProperties: AffiseInitProperties,
launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) {

self.app = app;
self.initProperties = initProperties;
Expand All @@ -23,7 +25,6 @@ internal class AffiseComponent: AffiseApi {
setPropertiesWhenInitUseCase.initialize(initProperties: initProperties)
sessionManager.initialize()
eventsManager.initialize()
advertisingIdManager.initialize()
// oaidManager.init(app)
// retrieveInstallReferrerUseCase.startInstallReferrerRetrieve()
deeplinkManager.initialize(launchOptions: launchOptions)
Expand Down Expand Up @@ -127,7 +128,6 @@ internal class AffiseComponent: AffiseApi {
isDeeplinkRepository: deeplinkClickRepository,
appLifecycleEventsManager: appLifecycleEventsManager
)
lazy var advertisingIdManager: AdvertisingIdManager = AdvertisingIdManagerImpl()
lazy var webBridgeManager: WebBridgeManager = WebBridgeManager(storeEventUseCase: storeEventUseCase)
lazy var preferencesUseCase: PreferencesUseCase = PreferencesUseCaseImpl(
repository: ApplicationLifecyclePreferencesRepositoryImpl(),
Expand All @@ -145,7 +145,6 @@ internal class AffiseComponent: AffiseApi {
lazy var postBackModelFactory: PostBackModelFactory = PropertiesProviderFactory(
app: app,
bundle: bundle,
advertisingIdManager: advertisingIdManager,
firstAppOpenUseCase: firstAppOpenUseCase,
webViewUseCase: webViewUseCase,
sessionManager: sessionManager,
Expand Down
21 changes: 15 additions & 6 deletions AffiseAttributionLib/Classes/modules/AffiseModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@ import UIKit

@objc
open class AffiseModule: NSObject {

public var app: UIApplication?
public var logsManager: LogsManager?
public var dependencies: [Any] = []
public var baseProviders: [Provider] = []

public required init(
public required override init(
) {
super.init()
}

open func dependencies(
app: UIApplication,
logsManager: LogsManager,
dependencies: [Any],
providers: [Provider]
) {
super.init()
self.app = app
self.logsManager = logsManager
self.dependencies = dependencies
self.baseProviders = providers
self.initialize()
}

open func initialize() {}

open func initialize() {

}

open func isManual() -> Bool {
false
}

open func providers() -> [Provider] {
return []
}
Expand Down
39 changes: 32 additions & 7 deletions AffiseAttributionLib/Classes/modules/AffiseModuleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,52 @@ internal class AffiseModuleManager {
app: UIApplication,
dependencies: [Any]
) {
for name in AffiseModules.values() {
guard let cls = classType(name) else { continue }

let module = cls.init(
initAffiseModules { module in
module.dependencies(
app: app,
logsManager: logsManager,
dependencies: dependencies,
providers: postBackModelFactory.getProviders()
)

postBackModelFactory.addProviders(module.providers())
modules[name] = module
if module.isManual() == false {
moduleStart(module)
}
}
}

func manualStart(_ module: AffiseModules) {
guard let affiseModule: AffiseModule = modules[module] else { return }
if affiseModule.isManual() == false { return }
moduleStart(affiseModule)
}

func status(_ module: AffiseModules, _ onComplete: @escaping OnKeyValueCallback) {
modules[module]?.status(onComplete) ?? onComplete([AffiseKeyValue(module.value(), "not found")])
getModule(module)?.status(onComplete) ?? onComplete([AffiseKeyValue(module.value(), "not found")])
}

private func moduleStart(_ module: AffiseModule) {
module.initialize()
postBackModelFactory.addProviders(module.providers())
}

private func classType(_ name: AffiseModules) -> AffiseModule.Type? {
guard let cls = NSClassFromString(name.value()) as? AffiseModule.Type else { return nil }
return cls
}

private func getModule(_ name: AffiseModules) -> AffiseModule? {
modules[name]
}

private func initAffiseModules(_ callback: (_ module: AffiseModule) -> Void) {
for name in AffiseModules.values() {
guard let cls = classType(name) else { continue }

let module = cls.init()
modules[name] = module

callback(module)
}
}
}
2 changes: 2 additions & 0 deletions AffiseAttributionLib/Classes/modules/AffiseModules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import Foundation

@objc
public enum AffiseModules: Int {
case Advertising
case Status

internal var enumValue: String {
switch self {
case .Advertising: return "Advertising"
case .Status: return "Status"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

/**
* Provider for parameter [ProviderType.RANDOM_USER_ID]
*
Expand All @@ -10,7 +12,7 @@ public class RandomUserIdProvider: StringPropertyProvider {
self.useCase = useCase
}

override func provide() -> String? {
public override func provide() -> String? {
return useCase.getRandomUserId()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
//
// PropertyProvider.swift
// app
//
// Created by Sergey Korney
//


/**
* Base property provider
*/
public class PropertyProvider<T> : Provider {
public func getOrder() -> Float {
open class PropertyProvider<T> : Provider {
open func getOrder() -> Float {
0
}

public func getKey() -> ProviderType? {
open func getKey() -> ProviderType? {
nil
}

Expand All @@ -30,7 +22,7 @@ public class PropertyProvider<T> : Provider {
/**
* Provide data
*/
func provide() -> T? { nil }
open func provide() -> T? { nil }

/**
* Provide data with default value
Expand All @@ -43,8 +35,8 @@ public class PropertyProvider<T> : Provider {
/**
* Base string property provider
*/
public class StringPropertyProvider : PropertyProvider<String> {
init() {
open class StringPropertyProvider : PropertyProvider<String> {
public init() {
super.init("")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ internal class PropertiesProviderFactory {

private let app: UIApplication
private let bundle: Bundle
private let advertisingIdManager: AdvertisingIdManager
private let firstAppOpenUseCase: FirstAppOpenUseCase
private let webViewUseCase: WebViewUseCase
private let sessionManager: SessionManager
Expand All @@ -24,7 +23,6 @@ internal class PropertiesProviderFactory {

init(app: UIApplication,
bundle: Bundle,
advertisingIdManager: AdvertisingIdManager,
firstAppOpenUseCase: FirstAppOpenUseCase,
webViewUseCase: WebViewUseCase,
sessionManager: SessionManager,
Expand All @@ -38,7 +36,6 @@ internal class PropertiesProviderFactory {
) {
self.app = app
self.bundle = bundle
self.advertisingIdManager = advertisingIdManager
self.firstAppOpenUseCase = firstAppOpenUseCase
self.webViewUseCase = webViewUseCase
self.sessionManager = sessionManager
Expand Down Expand Up @@ -87,7 +84,6 @@ internal class PropertiesProviderFactory {
EmptyStringProvider(ProviderType.DEVICE_ATLAS_ID, order: 26.0),
AffiseDeviceIdProvider(useCase: firstAppOpenUseCase),
AffiseAltDeviceIdProvider(useCase: firstAppOpenUseCase),
AdidProvider(advertisingIdManager: advertisingIdManager),
RefTokenProvider(preferences: preferences),
RefTokensProvider(preferences: preferences),
UserAgentProvider(useCase: webViewUseCase),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Foundation

/**
* Provider for parameter [ProviderType.AFFISE_SDK_VERSION]
*/
class AffSDKVersionProvider: StringPropertyProvider {

override func provide() -> String? {
return "1.6.17"
return "1.6.18"
}

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

/**
* Provider for parameter [ProviderType.AFFISE_APP_ID]
Expand All @@ -11,7 +12,7 @@ public class AffiseAppIdProvider: StringPropertyProvider {
self.storage = storage
}

override func provide() -> String? {
public override func provide() -> String? {
return storage.getProperties()?.affiseAppId
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation

/**
* Provider for parameter [ProviderType.AFFISE_DEVICE_ID]
Expand All @@ -11,7 +12,7 @@ public class AffiseDeviceIdProvider: StringPropertyProvider {
self.useCase = useCase
}

override func provide() -> String? {
public override func provide() -> String? {
return useCase.getAffiseDeviseId()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AffisePackageAppNameProvider: StringPropertyProvider {
self.bundle = bundle
}

override func provide() -> String? {
public override func provide() -> String? {
return bundle.bundleIdentifier
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
* Provider for parameter [ProviderType.CREATED_TIME]
*/
public class CreatedTimeProvider : LongPropertyProvider {
override func provide() -> Int64? {
public override func provide() -> Int64? {
return Date().timeIntervalSince1970.timeInMillis
}

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.17"
spec.version = ENV['LIB_VERSION'] || "1.6.18"
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: 2 additions & 0 deletions AffiseInternal/Classes/AffiseApiMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum AffiseApiMethod: Int {
case GET_RANDOM_USER_ID
case GET_RANDOM_DEVICE_ID
case GET_PROVIDERS
case MODULE_START
// callback
case GET_REFERRER_CALLBACK
case GET_REFERRER_VALUE_CALLBACK
Expand Down Expand Up @@ -59,6 +60,7 @@ public enum AffiseApiMethod: Int {
case .GET_RANDOM_USER_ID: return "get_random_user_id"
case .GET_RANDOM_DEVICE_ID: return "get_random_device_id"
case .GET_PROVIDERS: return "get_providers"
case .MODULE_START: return "module_start"
case .GET_REFERRER_CALLBACK: return "get_referrer_callback"
case .GET_REFERRER_VALUE_CALLBACK: return "get_referrer_value_callback"
case .GET_STATUS_CALLBACK: return "get_status_callback"
Expand Down
Loading

0 comments on commit 3737b01

Please sign in to comment.