Skip to content

Commit

Permalink
1.6.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Sep 8, 2023
1 parent d8ec655 commit 285099f
Show file tree
Hide file tree
Showing 28 changed files with 718 additions and 285 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.9"
spec.version = ENV['LIB_VERSION'] || "1.6.10"
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
6 changes: 6 additions & 0 deletions AffiseAttributionLib/Assets/affise.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ class Event {
AffiseLog.w(`${this.affise_event_name}: ${err}`);
}
);
return this;
}

// Send event
send() {
Affise.sendEvent(this);
}

_generateUUID() {
Expand Down
88 changes: 55 additions & 33 deletions AffiseAttributionLib/Classes/Affise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,84 +15,90 @@ import WebKit


@objc
public class Affise: NSObject {

public final class Affise: NSObject {

@available(*, deprecated, message: "remove .shared")
@objc
public static let shared = Affise()
public static let shared = AffiseShared()


/**
* Api to communication with Affise
*/
private var api: AffiseApi?
private static var api: AffiseApi?

/**
* Init [AffiseComponent] with [app] and [initProperties]
*/
@objc
public func load(app: UIApplication,
initProperties: AffiseInitProperties,
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {

if (self.api == nil) {
self.api = AffiseComponent(app: app, initProperties: initProperties, launchOptions: launchOptions)
public static func load(
app: UIApplication,
initProperties: AffiseInitProperties,
launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) {
if (api == nil) {
api = AffiseComponent(app: app, initProperties: initProperties, launchOptions: launchOptions)
}
}

@objc
public func isInitialized() -> Bool {
return self.api?.isInitialized() ?? false
public static func isInitialized() -> Bool {
return api?.isInitialized() ?? false
}

/**
* Send events
*/
@objc
public func sendEvents() {
public static func sendEvents() {
api?.eventsManager.sendEvents()
}

/**
* Store and send [event]
*/
@objc
public func sendEvent(event: Event) {
public static func sendEvent(_ event: Event) {
api?.storeEventUseCase.storeEvent(event: event)
}

/**
* Add [pushToken]
*/
public func addPushToken(pushToken: String) {
@objc
public static func addPushToken(_ pushToken: String) {
api?.preferences.set(pushToken, forKey: PushTokenProvider.KEY)
}

/**
* Register [webView] to WebBridge
*/
public func registerWebView(webView: WKWebView) {
@objc
public static func registerWebView(_ webView: WKWebView) {
api?.webBridgeManager.registerWebView(webView: webView)
}

/**
* Unregister webView on WebBridge
*/
public func unregisterWebView() {
@objc
public static func unregisterWebView() {
api?.webBridgeManager.unregisterWebView()
}


/**
* Register [callback] for deeplink
*/
public func registerDeeplinkCallback(callback: @escaping (_ url: URL) -> Void) {
@objc
public static func registerDeeplinkCallback(_ callback: @escaping (_ url: URL) -> Void) {
api?.deeplinkManager.setDeeplinkCallback(callback: callback)
}

/**
* Set new secretKey
*/
public func setSecretId(secretKey: String) {
@objc
public static func setSecretKey(_ secretKey: String) {
api?.initPropertiesStorage.updateSecretKey(secretKey: secretKey)
}

Expand All @@ -103,74 +109,90 @@ public class Affise: NSObject {
* but background work is not paused. When offline mode is enabled,
* all recorded events should be sent
*/
public func setOfflineModeEnabled(enabled: Bool) {
@objc
public static func setOfflineModeEnabled(_ enabled: Bool) {
api?.preferencesUseCase.setOfflineModeEnabled(enabled: enabled)
}

/**
* Returns current offline mode state
*/
public func isOfflineModeEnabled() -> Bool { return api?.preferencesUseCase.isOfflineModeEnabled() ?? false }
@objc
public static func isOfflineModeEnabled() -> Bool {
return api?.preferencesUseCase.isOfflineModeEnabled() ?? false
}

/**
* Sets background tracking mode to [enabled] state
*
* When disabled, library should not generate any tracking events while in background
*/
public func setBackgroundTrackingEnabled(enabled: Bool) {
@objc
public static func setBackgroundTrackingEnabled(_ enabled: Bool) {
api?.preferencesUseCase.setBackgroundTrackingEnabled(enabled: enabled)
}

/**
* Returns current background tracking state
*/
public func isBackgroundTrackingEnabled() -> Bool { return api?.preferencesUseCase.isBackgroundTrackingEnabled() ?? false }
@objc
public static func isBackgroundTrackingEnabled() -> Bool {
return api?.preferencesUseCase.isBackgroundTrackingEnabled() ?? false
}

/**
* Sets offline mode to [enabled] state
*
* When disabled, library should not generate any tracking events
*/
public func setTrackingEnabled(enabled: Bool) {
@objc
public static func setTrackingEnabled(_ enabled: Bool) {
api?.preferencesUseCase.setTrackingEnabled(enabled: enabled)
}

/**
* Returns current tracking state
*/
public func isTrackingEnabled() -> Bool { return api?.preferencesUseCase.isTrackingEnabled() ?? false }
@objc
public static func isTrackingEnabled() -> Bool {
return api?.preferencesUseCase.isTrackingEnabled() ?? false
}

/**
* Returns random User Id
*/
public func getRandomUserId() -> String? {
let provider : RandomUserIdProvider? = api?.postBackModelFactory.getProvider()
@objc
public static func getRandomUserId() -> String? {
let provider: RandomUserIdProvider? = api?.postBackModelFactory.getProvider()
return provider?.provide()
}

/**
* Returns random Device Id
*/
public func getRandomDeviceId() -> String? {
let provider : AffiseDeviceIdProvider? = api?.postBackModelFactory.getProvider()
@objc
public static func getRandomDeviceId() -> String? {
let provider: AffiseDeviceIdProvider? = api?.postBackModelFactory.getProvider()
return provider?.provide()
}

/**
* Get module status
*/
public func getStatus(_ module: AffiseModules, onComplete: @escaping (_ data: [AffiseKeyValue]) -> Void) {
@objc
public static func getStatus(_ module: AffiseModules, _ onComplete: @escaping (_ data: [AffiseKeyValue]) -> Void) {
api?.moduleManager.status(module, onComplete)
}

/**
* Call deeplink handle manually
*/
public func handleDeeplink(url: URL) {
@objc
public static func handleDeeplink(_ url: URL) {
api?.deeplinkManager.handleDeeplink(url: url)
}

internal func getApi() -> AffiseApi? {
internal static func getApi() -> AffiseApi? {
return api
}
}
5 changes: 4 additions & 1 deletion AffiseAttributionLib/Classes/AffiseComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ internal class AffiseComponent: AffiseApi {
lifetimeRepository: ApplicationLifetimePreferencesRepositoryImpl(userDefaults: preferences))

lazy var stringToSha256Converter: StringToSHA256Converter = StringToSHA256Converter()
lazy var deviceUseCase: DeviceUseCase = DeviceUseCaseImpl()

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

lazy var moduleManager: AffiseModuleManager = AffiseModuleManager(
Expand Down
Loading

0 comments on commit 285099f

Please sign in to comment.