@tyrads.com/tyrads-sdk 2.0.0-beta.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +11 -11
- package/android/build.gradle +117 -117
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/AndroidManifestNew.xml +2 -2
- package/android/src/main/java/com/tyradssdk/TyradsSdkComposeViewManager.kt +112 -112
- package/android/src/main/java/com/tyradssdk/TyradsSdkModule.kt +56 -56
- package/android/src/main/java/com/tyradssdk/TyradsSdkPackage.kt +18 -21
- package/ios/Tyrads/AcmoConfig.swift +32 -31
- package/ios/Tyrads/ApiHeaders.swift +12 -0
- package/ios/Tyrads/InitModel.swift +48 -46
- package/ios/Tyrads/Tyrads.swift +199 -176
- package/ios/TyradsSdk-Bridging-Header.h +2 -2
- package/ios/TyradsSdk.mm +14 -11
- package/ios/TyradsSdk.swift +47 -27
- package/lib/commonjs/acmo/core/marquee.js.map +1 -1
- package/lib/commonjs/acmo/core/storage/storage.js.map +1 -1
- package/lib/commonjs/acmo/core/types/types.d.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/auto_scroller.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/custom_card.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/my_games_button.js +3 -5
- package/lib/commonjs/acmo/modules/dashboard/components/my_games_button.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/offer_info_section.js +3 -8
- package/lib/commonjs/acmo/modules/dashboard/components/offer_info_section.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js +3 -3
- package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_1.js +2 -7
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_1.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_2.js +4 -6
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_2.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_3.js +4 -6
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_3.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_4.js +5 -6
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_4.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/repository.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/top_offers.js +23 -7
- package/lib/commonjs/acmo/modules/dashboard/top_offers.js.map +1 -1
- package/lib/commonjs/i18n.js.map +1 -1
- package/lib/commonjs/index.js +12 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/acmo/core/marquee.js.map +1 -1
- package/lib/module/acmo/core/storage/storage.js.map +1 -1
- package/lib/module/acmo/core/types/types.d.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/auto_scroller.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/custom_card.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/my_games_button.js +3 -5
- package/lib/module/acmo/modules/dashboard/components/my_games_button.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/offer_info_section.js +3 -8
- package/lib/module/acmo/modules/dashboard/components/offer_info_section.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_header.js +3 -3
- package/lib/module/acmo/modules/dashboard/components/premium_header.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_1.js +2 -7
- package/lib/module/acmo/modules/dashboard/components/premium_option_1.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_2.js +4 -6
- package/lib/module/acmo/modules/dashboard/components/premium_option_2.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_3.js +4 -6
- package/lib/module/acmo/modules/dashboard/components/premium_option_3.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_4.js +5 -6
- package/lib/module/acmo/modules/dashboard/components/premium_option_4.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/repository.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/top_offers.js +23 -7
- package/lib/module/acmo/modules/dashboard/top_offers.js.map +1 -1
- package/lib/module/i18n.js.map +1 -1
- package/lib/module/index.js +12 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/acmo/core/storage/storage.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/my_games_button.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/my_games_button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_info_section.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_info_section.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_header.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_1.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_1.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_2.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_2.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_3.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_3.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_4.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_4.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/repository.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/top_offers.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/core/storage/storage.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/my_games_button.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/my_games_button.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_info_section.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_info_section.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_header.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_1.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_1.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_2.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_2.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_3.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_3.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_4.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_4.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/repository.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/top_offers.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +197 -197
- package/readme.md +95 -97
- package/src/acmo/core/marquee.tsx +61 -61
- package/src/acmo/core/storage/storage.ts +27 -27
- package/src/acmo/core/types/types.d.ts +93 -93
- package/src/acmo/modules/dashboard/components/auto_scroller.tsx +84 -84
- package/src/acmo/modules/dashboard/components/custom_card.tsx +30 -30
- package/src/acmo/modules/dashboard/components/my_games_button.tsx +39 -39
- package/src/acmo/modules/dashboard/components/offer_info_section.tsx +138 -143
- package/src/acmo/modules/dashboard/components/premium_header.tsx +80 -80
- package/src/acmo/modules/dashboard/components/premium_option_1.tsx +155 -160
- package/src/acmo/modules/dashboard/components/premium_option_2.tsx +99 -103
- package/src/acmo/modules/dashboard/components/premium_option_3.tsx +41 -45
- package/src/acmo/modules/dashboard/components/premium_option_4.tsx +184 -183
- package/src/acmo/modules/dashboard/repository.ts +94 -94
- package/src/acmo/modules/dashboard/top_offers.tsx +144 -131
- package/src/i18n.ts +114 -114
- package/src/index.tsx +89 -81
- package/tyrads-sdk.podspec +41 -41
@@ -1,21 +1,18 @@
|
|
1
|
-
package com.tyradssdk
|
2
|
-
|
3
|
-
import com.facebook.react.ReactPackage
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
6
|
-
import com.facebook.react.uimanager.ViewManager
|
7
|
-
|
8
|
-
|
9
|
-
class TyradsSdkPackage : ReactPackage {
|
10
|
-
|
11
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
12
|
-
return listOf(TyradsSdkModule(reactContext))
|
13
|
-
}
|
14
|
-
|
15
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
16
|
-
return
|
17
|
-
}
|
18
|
-
|
19
|
-
// return listOf(ComposeViewManager())
|
20
|
-
// }
|
21
|
-
}
|
1
|
+
package com.tyradssdk
|
2
|
+
|
3
|
+
import com.facebook.react.ReactPackage
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
7
|
+
|
8
|
+
|
9
|
+
class TyradsSdkPackage : ReactPackage {
|
10
|
+
|
11
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
12
|
+
return listOf(TyradsSdkModule(reactContext))
|
13
|
+
}
|
14
|
+
|
15
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
16
|
+
return listOf(ComposeViewManager())
|
17
|
+
}
|
18
|
+
}
|
@@ -1,31 +1,32 @@
|
|
1
|
-
//
|
2
|
-
// AcmoConfig.swift
|
3
|
-
// TyradsSdk
|
4
|
-
//
|
5
|
-
// Created by ibnShamas on 8/13/24.
|
6
|
-
//
|
7
|
-
|
8
|
-
import Foundation
|
9
|
-
import UIKit
|
10
|
-
|
11
|
-
struct AcmoConfig {
|
12
|
-
static let API_VERSION = "
|
13
|
-
static let BUILD_VERSION = "
|
14
|
-
static let
|
15
|
-
static let
|
16
|
-
static let
|
17
|
-
static let
|
18
|
-
|
19
|
-
|
20
|
-
static let
|
21
|
-
static let
|
22
|
-
|
23
|
-
|
24
|
-
static let
|
25
|
-
static let
|
26
|
-
static let
|
27
|
-
static let
|
28
|
-
|
29
|
-
|
30
|
-
//
|
31
|
-
|
1
|
+
//
|
2
|
+
// AcmoConfig.swift
|
3
|
+
// TyradsSdk
|
4
|
+
//
|
5
|
+
// Created by ibnShamas on 8/13/24.
|
6
|
+
//
|
7
|
+
|
8
|
+
import Foundation
|
9
|
+
import UIKit
|
10
|
+
|
11
|
+
struct AcmoConfig {
|
12
|
+
static let API_VERSION = "2.0"
|
13
|
+
static let BUILD_VERSION = "1"
|
14
|
+
static let ACMO_VERSION = "3"
|
15
|
+
static let SDK_VERSION = "\(API_VERSION).\(BUILD_VERSION)"
|
16
|
+
static let SDK_PLATFORM = "React Native"
|
17
|
+
static let BASE_URL = "https://api.tyrads.com/v\(API_VERSION)/"
|
18
|
+
static let TAG = "TyrAds SDK"
|
19
|
+
|
20
|
+
static let PRIMARY_COLOR = UIColor(red: 0/255, green: 36/255, blue: 51/255, alpha: 1)
|
21
|
+
static let PRIMARY_COLOR_LIGHT = UIColor(red: 153/255, green: 145/255, blue: 145/255, alpha: 1)
|
22
|
+
static let PRIMARY_COLOR_DARK = UIColor.black
|
23
|
+
|
24
|
+
static let SECONDARY_COLOR = UIColor(red: 44/255, green: 179/255, blue: 136/255, alpha: 1)
|
25
|
+
static let SECONDARY_COLOR_LIGHT = UIColor(red: 203/255, green: 235/255, blue: 207/255, alpha: 1)
|
26
|
+
static let SIDEBAR_BACKGROUND_COLOR_LIGHT = UIColor(white: 1, alpha: 0.54)
|
27
|
+
static let SIDEBAR_BACKGROUND_COLOR_DARK = UIColor(red: 17/255, green: 45/255, blue: 30/255, alpha: 1)
|
28
|
+
static let APPBAR_BG = UIColor(red: 0/255, green: 33/255, blue: 48/255, alpha: 1)
|
29
|
+
|
30
|
+
// Note: ThemeMode.light doesn't have a direct equivalent in iOS
|
31
|
+
// You would typically handle this in your app's theme configuration
|
32
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
public struct ApiHeaders {
|
2
|
+
let xApiKey: String
|
3
|
+
let xApiSecret: String
|
4
|
+
let xUserId: String
|
5
|
+
let xSdkPlatform: String?
|
6
|
+
let xSdkVersion: String?
|
7
|
+
let userAgent: String
|
8
|
+
let languageCode: String
|
9
|
+
let premiumColor: String
|
10
|
+
let headerColor: String
|
11
|
+
let mainColor: String
|
12
|
+
}
|
@@ -1,46 +1,48 @@
|
|
1
|
-
//
|
2
|
-
// InitModel.swift
|
3
|
-
// TyradsSdk
|
4
|
-
//
|
5
|
-
// Created by ibnShamas on 8/13/24.
|
6
|
-
//
|
7
|
-
|
8
|
-
import Foundation
|
9
|
-
|
10
|
-
struct AcmoInitModel: Codable {
|
11
|
-
let data: Data
|
12
|
-
}
|
13
|
-
|
14
|
-
struct Data: Codable {
|
15
|
-
let newRegisteredUser: Bool
|
16
|
-
let user: User
|
17
|
-
let publisherApp: PublisherApp
|
18
|
-
|
19
|
-
enum CodingKeys: String, CodingKey {
|
20
|
-
case newRegisteredUser = "newRegisteredUser"
|
21
|
-
case user
|
22
|
-
case publisherApp
|
23
|
-
}
|
24
|
-
|
25
|
-
init(from decoder: Decoder) throws {
|
26
|
-
let container = try decoder.container(keyedBy: CodingKeys.self)
|
27
|
-
newRegisteredUser = try container.decodeIfPresent(Bool.self, forKey: .newRegisteredUser) ?? false
|
28
|
-
user = try container.decode(User.self, forKey: .user)
|
29
|
-
publisherApp = try container.decode(PublisherApp.self, forKey: .publisherApp)
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
struct User: Codable {
|
34
|
-
let publisherUserId: String
|
35
|
-
}
|
36
|
-
|
37
|
-
struct PublisherApp: Codable {
|
38
|
-
let headerColor: String
|
39
|
-
let mainColor: String
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
1
|
+
//
|
2
|
+
// InitModel.swift
|
3
|
+
// TyradsSdk
|
4
|
+
//
|
5
|
+
// Created by ibnShamas on 8/13/24.
|
6
|
+
//
|
7
|
+
|
8
|
+
import Foundation
|
9
|
+
|
10
|
+
struct AcmoInitModel: Codable {
|
11
|
+
let data: Data
|
12
|
+
}
|
13
|
+
|
14
|
+
struct Data: Codable {
|
15
|
+
let newRegisteredUser: Bool
|
16
|
+
let user: User
|
17
|
+
let publisherApp: PublisherApp
|
18
|
+
|
19
|
+
enum CodingKeys: String, CodingKey {
|
20
|
+
case newRegisteredUser = "newRegisteredUser"
|
21
|
+
case user
|
22
|
+
case publisherApp
|
23
|
+
}
|
24
|
+
|
25
|
+
init(from decoder: Decoder) throws {
|
26
|
+
let container = try decoder.container(keyedBy: CodingKeys.self)
|
27
|
+
newRegisteredUser = try container.decodeIfPresent(Bool.self, forKey: .newRegisteredUser) ?? false
|
28
|
+
user = try container.decode(User.self, forKey: .user)
|
29
|
+
publisherApp = try container.decode(PublisherApp.self, forKey: .publisherApp)
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
struct User: Codable {
|
34
|
+
let publisherUserId: String
|
35
|
+
}
|
36
|
+
|
37
|
+
struct PublisherApp: Codable {
|
38
|
+
let headerColor: String
|
39
|
+
let mainColor: String
|
40
|
+
let premiumColor: String
|
41
|
+
|
42
|
+
init(from decoder: Decoder) throws {
|
43
|
+
let container = try decoder.container(keyedBy: CodingKeys.self)
|
44
|
+
headerColor = try container.decodeIfPresent(String.self, forKey: .headerColor) ?? ""
|
45
|
+
mainColor = try container.decodeIfPresent(String.self, forKey: .mainColor) ?? ""
|
46
|
+
premiumColor = try container.decodeIfPresent(String.self, forKey: .premiumColor) ?? ""
|
47
|
+
}
|
48
|
+
}
|
package/ios/Tyrads/Tyrads.swift
CHANGED
@@ -1,176 +1,199 @@
|
|
1
|
-
import Foundation
|
2
|
-
import UIKit
|
3
|
-
import AppTrackingTransparency
|
4
|
-
import AdSupport
|
5
|
-
import WebKit
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
/// The TyradsSdk class provides methods for configuring the SDK and displaying offers.
|
10
|
-
public class Tyrads {
|
11
|
-
/// Shared instance of the TyradsSdk.
|
12
|
-
public static let instance = Tyrads()
|
13
|
-
|
14
|
-
private var apiKey: String = ""
|
15
|
-
private var apiSecret: String = ""
|
16
|
-
private var publisherUserID: String = ""
|
17
|
-
private var
|
18
|
-
private var
|
19
|
-
var
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
///
|
30
|
-
///
|
31
|
-
///
|
32
|
-
/// -
|
33
|
-
|
34
|
-
|
35
|
-
self.
|
36
|
-
self.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
///
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
1
|
+
import Foundation
|
2
|
+
import UIKit
|
3
|
+
import AppTrackingTransparency
|
4
|
+
import AdSupport
|
5
|
+
import WebKit
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
/// The TyradsSdk class provides methods for configuring the SDK and displaying offers.
|
10
|
+
public class Tyrads {
|
11
|
+
/// Shared instance of the TyradsSdk.
|
12
|
+
public static let instance = Tyrads()
|
13
|
+
|
14
|
+
private var apiKey: String = ""
|
15
|
+
private var apiSecret: String = ""
|
16
|
+
private var publisherUserID: String = ""
|
17
|
+
private var currentLanguage: String = "en"
|
18
|
+
private var newUser: Bool = false
|
19
|
+
private var loginData: AcmoInitModel?
|
20
|
+
var initializationWait = DispatchSemaphore(value: 0)
|
21
|
+
private var debugMode: Bool = false
|
22
|
+
|
23
|
+
private func log(_ message: String) {
|
24
|
+
if debugMode {
|
25
|
+
NSLog(message)
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
/// Configures the Tyrads SDK with the provided API key and secret key.
|
30
|
+
///
|
31
|
+
/// - Parameters:
|
32
|
+
/// - apiKey: The API key provided by Tyrads.
|
33
|
+
/// - secretKey: The secret key provided by Tyrads.
|
34
|
+
@objc public func configure( apiKey: String, secretKey: String, debugMode: Bool = false) {
|
35
|
+
self.apiKey = apiKey
|
36
|
+
self.apiSecret = secretKey
|
37
|
+
self.debugMode = debugMode
|
38
|
+
self.currentLanguage = Locale.current.languageCode ?? ""
|
39
|
+
}
|
40
|
+
|
41
|
+
/// Logs in the user with the provided user ID or retrieves the user ID from UserDefaults.
|
42
|
+
///
|
43
|
+
/// - Parameter userID: Optional. The user ID to log in with. If nil, the SDK will attempt to retrieve the user ID from UserDefaults.
|
44
|
+
public func loginUser(_ userID: String? = nil, completion: @escaping (ApiHeaders?) -> Void) {
|
45
|
+
let userId = userID ?? UserDefaults.standard.string(forKey: "acmo-tyrads-sdk-user-id") ?? ""
|
46
|
+
|
47
|
+
let identifierType = "IDFA"
|
48
|
+
var advertisingId = ""
|
49
|
+
|
50
|
+
func finalizeLogin() {
|
51
|
+
let fd: [String: Any] = [
|
52
|
+
"publisherUserId": userId,
|
53
|
+
"platform": "iOS",
|
54
|
+
"identifierType": identifierType,
|
55
|
+
"identifier": advertisingId
|
56
|
+
]
|
57
|
+
|
58
|
+
self.log("Initializing with data: \(fd)")
|
59
|
+
|
60
|
+
guard let url = URL(string: AcmoConfig.BASE_URL + "initialize") else {
|
61
|
+
self.log("Failed to create URL")
|
62
|
+
completion(nil)
|
63
|
+
return
|
64
|
+
}
|
65
|
+
|
66
|
+
var request = URLRequest(url: url)
|
67
|
+
request.httpMethod = "POST"
|
68
|
+
request.setValue(AcmoConfig.SDK_PLATFORM, forHTTPHeaderField: "X-SDK-Platform")
|
69
|
+
request.setValue(AcmoConfig.SDK_VERSION, forHTTPHeaderField: "X-SDK-Version")
|
70
|
+
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
71
|
+
request.setValue(self.apiKey, forHTTPHeaderField: "X-API-Key")
|
72
|
+
request.setValue(self.apiSecret, forHTTPHeaderField: "X-API-Secret")
|
73
|
+
|
74
|
+
do {
|
75
|
+
request.httpBody = try JSONSerialization.data(withJSONObject: fd)
|
76
|
+
} catch {
|
77
|
+
self.log("Failed to serialize request body: \(error)")
|
78
|
+
completion(nil)
|
79
|
+
return
|
80
|
+
}
|
81
|
+
|
82
|
+
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
83
|
+
if let error = error {
|
84
|
+
self.log("Network request failed: \(error)")
|
85
|
+
completion(nil)
|
86
|
+
return
|
87
|
+
}
|
88
|
+
|
89
|
+
guard let data = data else {
|
90
|
+
self.log("No data received from the server")
|
91
|
+
completion(nil)
|
92
|
+
return
|
93
|
+
}
|
94
|
+
|
95
|
+
if let responseString = String(data: data, encoding: .utf8) {
|
96
|
+
self.log("Received response: \(responseString)")
|
97
|
+
|
98
|
+
guard let jsonData = responseString.data(using: .utf8),
|
99
|
+
let acmoInitModel = try? JSONDecoder().decode(AcmoInitModel.self, from: jsonData) else {
|
100
|
+
self.log("Failed to decode response")
|
101
|
+
completion(nil)
|
102
|
+
return
|
103
|
+
}
|
104
|
+
|
105
|
+
self.loginData = acmoInitModel
|
106
|
+
self.publisherUserID = acmoInitModel.data.user.publisherUserId
|
107
|
+
self.newUser = acmoInitModel.data.newRegisteredUser
|
108
|
+
self.log("Login successful. Publisher User ID: \(self.publisherUserID), New User: \(self.newUser)")
|
109
|
+
self.initializationWait.signal()
|
110
|
+
|
111
|
+
// Build ApiHeaders object
|
112
|
+
let headers = ApiHeaders(
|
113
|
+
xApiKey: self.apiKey,
|
114
|
+
xApiSecret: self.apiSecret,
|
115
|
+
xUserId: self.publisherUserID,
|
116
|
+
xSdkPlatform: AcmoConfig.SDK_PLATFORM,
|
117
|
+
xSdkVersion: AcmoConfig.SDK_VERSION,
|
118
|
+
userAgent: UIDevice.current.systemName + "/" + UIDevice.current.systemVersion,
|
119
|
+
languageCode: Locale.current.languageCode ?? "en",
|
120
|
+
premiumColor: acmoInitModel.data.publisherApp.premiumColor,
|
121
|
+
headerColor: acmoInitModel.data.publisherApp.headerColor,
|
122
|
+
mainColor: acmoInitModel.data.publisherApp.mainColor
|
123
|
+
)
|
124
|
+
|
125
|
+
completion(headers)
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
task.resume()
|
130
|
+
self.log("Network request started")
|
131
|
+
}
|
132
|
+
|
133
|
+
if #available(iOS 14, *) {
|
134
|
+
self.log("Requesting tracking authorization for iOS 14+")
|
135
|
+
ATTrackingManager.requestTrackingAuthorization { status in
|
136
|
+
switch status {
|
137
|
+
case .authorized:
|
138
|
+
advertisingId = ASIdentifierManager.shared().advertisingIdentifier.uuidString
|
139
|
+
self.log("Tracking authorized. Advertising ID: \(advertisingId)")
|
140
|
+
case .denied, .restricted, .notDetermined:
|
141
|
+
advertisingId = ""
|
142
|
+
self.log("Tracking not authorized or restricted")
|
143
|
+
@unknown default:
|
144
|
+
self.log("Unknown tracking status")
|
145
|
+
}
|
146
|
+
finalizeLogin()
|
147
|
+
}
|
148
|
+
} else {
|
149
|
+
advertisingId = ASIdentifierManager.shared().advertisingIdentifier.uuidString
|
150
|
+
self.log("iOS version < 14. Advertising ID: \(advertisingId)")
|
151
|
+
finalizeLogin()
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
public func showOffers(_ launchMode: Int = 3, route: String? = nil, campaignID: Int? = nil) {
|
159
|
+
self.initializationWait.wait()
|
160
|
+
var campaignIDString: String = "0"
|
161
|
+
if let campaignIDValue = campaignID {
|
162
|
+
campaignIDString = String(campaignIDValue)
|
163
|
+
}
|
164
|
+
let urlString =
|
165
|
+
"https://websdk.tyrads.com/?apiKey=\(Tyrads.instance.apiKey)&apiSecret=\(Tyrads.instance.apiSecret)&userID=\(Tyrads.instance.publisherUserID)&newUser=\(Tyrads.instance.newUser)&platform=\(AcmoConfig.SDK_PLATFORM)&hc=\(Tyrads.instance.loginData?.data.publisherApp.headerColor ?? "")&mc=\(Tyrads.instance.loginData?.data.publisherApp.mainColor ?? "")&launchMode=\(launchMode)&route=\(route ?? "")&campaignID=\(campaignIDString)&lang=\(Tyrads.instance.currentLanguage)&av=\(AcmoConfig.ACMO_VERSION)"
|
166
|
+
|
167
|
+
do {
|
168
|
+
guard let url = URL(string: urlString) else {
|
169
|
+
throw NSError(domain: "TyradsSdk", code: 1, userInfo: [NSLocalizedDescriptionKey: "Invalid URL"])
|
170
|
+
}
|
171
|
+
|
172
|
+
switch launchMode {
|
173
|
+
case 1, 2:
|
174
|
+
DispatchQueue.main.async {
|
175
|
+
let webView = WKWebView(frame: UIScreen.main.bounds)
|
176
|
+
webView.load(URLRequest(url: url))
|
177
|
+
|
178
|
+
let viewController = UIViewController()
|
179
|
+
viewController.view = webView
|
180
|
+
viewController.modalPresentationStyle = .fullScreen // Add this line to set the presentation style
|
181
|
+
|
182
|
+
if let rootViewController = UIApplication.shared.windows.first?.rootViewController {
|
183
|
+
rootViewController.present(viewController, animated: true, completion: nil)
|
184
|
+
}
|
185
|
+
}
|
186
|
+
case 3:
|
187
|
+
DispatchQueue.main.async {
|
188
|
+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
189
|
+
}
|
190
|
+
default:
|
191
|
+
DispatchQueue.main.async {
|
192
|
+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
193
|
+
}
|
194
|
+
}
|
195
|
+
} catch {
|
196
|
+
print("An error occurred: \(error)")
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
2
|
-
#import <React/RCTViewManager.h>
|
1
|
+
#import <React/RCTBridgeModule.h>
|
2
|
+
#import <React/RCTViewManager.h>
|
package/ios/TyradsSdk.mm
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
2
|
-
|
3
|
-
@interface RCT_EXTERN_MODULE(TyradsSdk, NSObject)
|
4
|
-
|
5
|
-
RCT_EXTERN_METHOD(init:(NSString *)apiKey secretKey:(NSString *)secretKey)
|
6
|
-
RCT_EXTERN_METHOD(loginUser:(NSString *)userId)
|
7
|
-
RCT_EXTERN_METHOD(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
#import <React/RCTBridgeModule.h>
|
2
|
+
|
3
|
+
@interface RCT_EXTERN_MODULE(TyradsSdk, NSObject)
|
4
|
+
|
5
|
+
RCT_EXTERN_METHOD(init:(NSString *)apiKey secretKey:(NSString *)secretKey)
|
6
|
+
// RCT_EXTERN_METHOD(loginUser:(NSString *)userId)
|
7
|
+
RCT_EXTERN_METHOD(loginUser:(NSString *)userId
|
8
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
9
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
10
|
+
RCT_EXTERN_METHOD(showOffers:(NSInteger)launchMode
|
11
|
+
route:(NSString)route
|
12
|
+
campaignID:(NSInteger)campaignID)
|
13
|
+
|
14
|
+
@end
|