Skip to content

Commit

Permalink
1.6.33
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Jun 28, 2024
1 parent 641006d commit 07b2f47
Show file tree
Hide file tree
Showing 39 changed files with 707 additions and 174 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Create AffiseAttributionLib XCFramework
uses: unsignedapps/swift-create-xcframework@v2.3.0
with:
target: "AffiseAttributionLib, AffiseModuleAdvertising, AffiseModuleStatus, AffiseModuleSubscription"
target: "AffiseAttributionLib, AffiseModuleAdvertising, AffiseModuleLink, AffiseModuleStatus, AffiseModuleSubscription"

# Release
- name: Release
Expand All @@ -68,6 +68,18 @@ jobs:
asset_name: AffiseAttributionLib-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
asset_content_type: application/zip

# Upload AffiseModuleLink
- name: Upload Release AffiseModuleLink Framework 🗳
if: ${{ success() }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AffiseModuleLink.zip
asset_name: AffiseModuleLink-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
asset_content_type: application/zip

# Upload AffiseModuleStatus
- name: Upload Release AffiseModuleStatus Framework 🗳
if: ${{ success() }}
Expand Down
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.32"
spec.version = ENV['LIB_VERSION'] || "1.6.33"
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
46 changes: 44 additions & 2 deletions AffiseAttributionLib/Classes/Affise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public final class Affise: NSObject {
* Register [callback] for deeplink
*/
@objc
public static func registerDeeplinkCallback(_ callback: @escaping OnDeeplinkCallback) {
public static func registerDeeplinkCallback(_ callback: OnDeeplinkCallback?) {
api?.deeplinkManager.setDeeplinkCallback(callback: callback)
}

Expand Down Expand Up @@ -216,6 +216,7 @@ public final class Affise: NSObject {
/**
* Get module status
*/
@available(*, deprecated, message: "Method moved to Affise.Module", renamed: "Module.getStatus")
@objc
public static func getStatus(_ module: AffiseModules, _ onComplete: @escaping OnKeyValueCallback) {
api?.moduleManager.status(module, onComplete)
Expand All @@ -224,6 +225,7 @@ public final class Affise: NSObject {
/**
* Manual module start
*/
@available(*, deprecated, message: "Method moved to Affise.Module", renamed: "Module.moduleStart")
@objc
@discardableResult
public static func moduleStart(_ module: AffiseModules) -> Bool {
Expand All @@ -233,6 +235,7 @@ public final class Affise: NSObject {
/**
* Get installed modules
*/
@available(*, deprecated, message: "Method moved to Affise.Module", renamed: "Module.getModulesInstalledObjc")
@objc
public static func getModulesInstalledObjc() -> [String] {
return api?.moduleManager.getModules().map { $0.description } ?? []
Expand All @@ -241,6 +244,7 @@ public final class Affise: NSObject {
/**
* Get installed modules
*/
@available(*, deprecated, message: "Method moved to Affise.Module", renamed: "Module.getModulesInstalled")
public static func getModulesInstalled() -> [AffiseModules] {
return api?.moduleManager.getModules() ?? []
}
Expand All @@ -256,7 +260,7 @@ public final class Affise: NSObject {
internal static func getApi() -> AffiseApi? {
return api
}

/**
* Store internal send
*/
Expand All @@ -265,6 +269,44 @@ public final class Affise: NSObject {
api?.storeInternalEventUseCase.storeInternalEvent(event: event)
}

public class Module {
/**
* Get module status
*/
@objc
public static func getStatus(_ module: AffiseModules, _ onComplete: @escaping OnKeyValueCallback) {
api?.moduleManager.status(module, onComplete)
}

/**
* Manual module start
*/
@objc
@discardableResult
public static func moduleStart(_ module: AffiseModules) -> Bool {
return api?.moduleManager.manualStart(module) ?? false
}

/**
* Get installed modules
*/
@objc
public static func getModulesInstalledObjc() -> [String] {
return api?.moduleManager.getModules().map { $0.description } ?? []
}

/**
* Get installed modules
*/
public static func getModulesInstalled() -> [AffiseModules] {
return api?.moduleManager.getModules() ?? []
}

internal static func getApi(_ module: AffiseModules) -> AffiseModuleApi? {
return api?.moduleManager.api(module)
}
}

public class Debug {
/**
* Won't work on Production
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class DebugValidateUseCaseImpl {
method: .POST,
data: converter.convert(from: providers).toData(),
timeout: TIMEOUT_SEND,
headers: CloudConfig.headers
headers: CloudConfig.headers,
redirect: true
)
}

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
*/
public typealias OnDeeplinkCallback = (_ url: URL?) -> Void
public typealias OnDeeplinkCallback = (_ value: DeeplinkValue) -> Void

/**
* Manager that coordinates deeplink related tasks
Expand All @@ -19,7 +19,7 @@ protocol DeeplinkManager {
/**
* Sets [callback] to invoke when app receives deeplink
*/
func setDeeplinkCallback(callback: @escaping OnDeeplinkCallback)
func setDeeplinkCallback(callback: OnDeeplinkCallback?)

/**
* Process [uri] as deeplink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ internal class DeeplinkManagerImpl : DeeplinkManager {
}
}

func setDeeplinkCallback(callback: @escaping OnDeeplinkCallback) {
func setDeeplinkCallback(callback: OnDeeplinkCallback?) {
deeplinkCallback = callback
}

func handleDeeplink(url: URL?) {
isDeeplinkRepository.setDeeplinkClick(isDeeplink: true)
isDeeplinkRepository.setDeeplink(deeplink: url?.absoluteString ?? "")
deeplinkCallback?(url)
deeplinkCallback?(url.toDeeplinkValue())
}
}
81 changes: 81 additions & 0 deletions AffiseAttributionLib/Classes/deeplink/DeeplinkValue.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import Foundation


@objc
public class DeeplinkValue: NSObject {

public let deeplink: String
public let scheme: String?
public let host: String?
public let path: String?
public let parameters: [String:[String]]

init(
deeplink: String,
scheme: String?,
host: String?,
path: String?,
parameters: [String:[String]]
) {
self.deeplink = deeplink
self.scheme = scheme
self.host = host
self.path = path
self.parameters = parameters
}
}

extension DeeplinkValue {
public override var description: String { "DeeplinkValue(scheme=\"\(self.scheme ?? "")\", host=\"\(self.host ?? "")\", path=\"\(self.path ?? "")\", parameters=\(self.parameters))" }
}


extension Optional where Wrapped == URL {

func toDeeplinkValue() -> DeeplinkValue {
guard let self = self else {
return DeeplinkValue(
deeplink: "",
scheme: nil,
host: nil,
path: nil,
parameters: [:]
)
}

var host: String?
var path: String?
var parameters: [String:[String]] = [:]

if #available(iOS 16.0, *) {
#if swift(>=5.7.1)
host = self.host(percentEncoded: false)
path = self.path(percentEncoded: false)
#else
host = self.host
path = self.path
#endif
} else {
host = self.host
path = self.path
}

let component = URLComponents(string: self.absoluteString)
for item in component?.queryItems ?? [] {
let value = item.value?.removingPercentEncoding
if parameters[item.name] != nil {
parameters[item.name]?.append(value ?? "")
} else {
parameters[item.name] = [value ?? ""]
}
}

return DeeplinkValue(
deeplink: self.absoluteString,
scheme: self.scheme,
host: host,
path: path,
parameters: parameters
)
}
}
3 changes: 3 additions & 0 deletions AffiseAttributionLib/Classes/modules/AffiseModuleApi.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol AffiseModuleApi {

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ internal class AffiseModuleManager {
callback(module)
}
}

func api(_ module: AffiseModules) -> AffiseModuleApi? {
return getModule(module) as? AffiseModuleApi
}
}
2 changes: 2 additions & 0 deletions AffiseAttributionLib/Classes/modules/AffiseModules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import Foundation
@objc
public enum AffiseModules: Int {
case Advertising
case Link
case Status
case Subscription

internal var enumValue: String {
switch self {
case .Advertising: return "Advertising"
case .Link: return "Link"
case .Status: return "Status"
case .Subscription: return "Subscription"
}
Expand Down
33 changes: 33 additions & 0 deletions AffiseAttributionLib/Classes/modules/link/AffiseLink.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Foundation

class AffiseLink {
private static var api: AffiseLinkApi? {
get {
if module != nil {
return module
} else {
module = Affise.Module.getApi(.Link) as? AffiseLinkApi
}
return module
}
}

private static var module: AffiseLinkApi? = nil

/**
* Module Link url Resolve
*/
public static func linkResolve(_ url: String, _ callback: @escaping AffiseLinkCallback) {
api?.linkResolve(url, callback) ?? callback("")
}
}

extension Affise.Module {

/**
* Module Link url Resolve
*/
public static func linkResolve(_ url: String, _ callback: @escaping AffiseLinkCallback) {
AffiseLink.linkResolve(url, callback)
}
}
5 changes: 5 additions & 0 deletions AffiseAttributionLib/Classes/modules/link/AffiseLinkApi.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

public protocol AffiseLinkApi: AffiseModuleApi {
func linkResolve(_ url: String, _ callback: @escaping AffiseLinkCallback)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Foundation

public typealias AffiseLinkCallback = (_ result: String) -> Void
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class AffiseSubscription {
private static var api: AffiseSubscriptionApi? {
get {
if module != nil {
return module
} else {
module = Affise.Module.getApi(.Subscription) as? AffiseSubscriptionApi
}
return module
}
}

private static var module: AffiseSubscriptionApi? = nil

public static func hasSubscriptionModule() -> Bool {
return api != nil
}

public static func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>) {
api?.fetchProducts(productsIds, callback)
}

public static func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>) {
api?.purchase(product, type, callback)
}
}


extension Affise.Module {
public static func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>) {
AffiseSubscription.fetchProducts(productsIds, callback)
}

public static func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>) {
AffiseSubscription.purchase(product, type, callback)
}

public static func hasSubscriptionModule() -> Bool {
return AffiseSubscription.hasSubscriptionModule()
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Foundation


public protocol AffiseSubscriptionApi {
static func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>)
public protocol AffiseSubscriptionApi : AffiseModuleApi {
func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>)

static func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>)
func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>)
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ extension CloudRepositoryImpl: CloudRepository {
method: .POST,
data: converter.convert(from: data).toData(),
timeout: TIMEOUT_SEND,
headers: createHeaders()
headers: createHeaders(),
redirect: true
)
}
}
Loading

0 comments on commit 07b2f47

Please sign in to comment.