@tyrads.com/tyrads-sdk 4.0.0 → 4.0.2-beta.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.
@@ -112,6 +112,6 @@ dependencies {
112
112
  implementation "com.facebook.react:react-native:+"
113
113
  implementation 'com.google.code.gson:gson:+'
114
114
 
115
- implementation 'com.github.tyrads-com:tyrads-sdk-android:22b7882c30'
115
+ implementation 'com.github.tyrads-com:tyrads-sdk-android:9abcc6b935'
116
116
  }
117
117
 
@@ -41,8 +41,6 @@ public class Tyrads : NSObject {
41
41
  }
42
42
  }
43
43
 
44
- private var preloadedWebVC: AcmoWebViewController?
45
-
46
44
  internal func log(_ message: String) {
47
45
  if debugMode {
48
46
  NSLog(message)
@@ -197,6 +195,8 @@ public class Tyrads : NSObject {
197
195
  self.publisherUserID = acmoInitModel.data.accountInfo.publisherUserId
198
196
  self.newUser = acmoInitModel.data.newRegisteredUser
199
197
  self.token = acmoInitModel.data.token
198
+ self.initializationContinuation?.resume()
199
+ self.initializationContinuation = nil
200
200
  self.log("Login successful. Publisher User ID: \(self.publisherUserID), New User: \(self.newUser)")
201
201
  self.mainColor = acmoInitModel.data.appInfo.mainColor
202
202
 
@@ -214,10 +214,6 @@ public class Tyrads : NSObject {
214
214
  privacyAccepted: hasAccepted
215
215
  )
216
216
 
217
- Task { @MainActor in
218
- self.preloadOffers()
219
- }
220
-
221
217
  return headers
222
218
  }
223
219
 
@@ -242,36 +238,7 @@ public class Tyrads : NSObject {
242
238
  return components.url
243
239
  }
244
240
 
245
- @MainActor
246
- public func preloadOffers(route: String? = nil) {
247
- let normalizedRoute = (route?.isEmpty ?? true) ? nil : route
248
-
249
- // only preload the default offerwall (no specific route)
250
- if normalizedRoute != nil {
251
- self.log("Preload: Skipping specific route \(normalizedRoute!)")
252
- return
253
- }
254
-
255
- guard !self.token.isEmpty else {
256
- self.log("Preload failed: token is empty")
257
- return
258
- }
259
- guard let url = getOffersURL(route: nil) else {
260
- self.log("Preload failed: failed to generate URL")
261
- return
262
- }
263
-
264
- self.log("Preloading default webview for URL: \(url.absoluteString)")
265
-
266
- if let existing = self.preloadedWebVC, existing.initialURL.absoluteString == url.absoluteString {
267
- self.log("Preload: Already have a matching preloaded VC, skipping recreation.")
268
- return
269
- }
270
-
271
- let webVC = AcmoWebViewController(url: url)
272
- _ = webVC.view
273
- self.preloadedWebVC = webVC
274
- }
241
+
275
242
 
276
243
  public func showOffers(_ launchMode: Int = 2, route: String? = nil, campaignID: Int? = nil) async {
277
244
  await ensureInitialized()
@@ -289,43 +256,7 @@ public class Tyrads : NSObject {
289
256
  let showWebView: () -> Void = {
290
257
  let webVC: AcmoWebViewController
291
258
 
292
- let isDefault = (route?.isEmpty ?? true) && campaignID == nil
293
-
294
- let isMatch: Bool = {
295
- guard isDefault else { return false }
296
-
297
- guard let preloaded = self.preloadedWebVC else {
298
- self.log("Preload Check: No preloaded webview found.")
299
- return false
300
- }
301
- let preloadedURL = preloaded.initialURL
302
-
303
- if preloadedURL.absoluteString == url.absoluteString { return true }
304
-
305
- guard let comp1 = URLComponents(url: preloadedURL, resolvingAgainstBaseURL: false),
306
- let comp2 = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return false }
307
-
308
- let q1 = comp1.queryItems ?? []
309
- let q2 = comp2.queryItems ?? []
310
-
311
- if q1.count != q2.count {
312
- return false
313
- }
314
-
315
- let matchesAll = q1.allSatisfy { item1 in
316
- q2.contains { item2 in item1.name == item2.name && item1.value == item2.value }
317
- }
318
-
319
- return matchesAll && comp1.host == comp2.host && comp1.path == comp2.path
320
- }()
321
-
322
- if isMatch, let preloaded = self.preloadedWebVC {
323
- self.log("Preload Check: MATCH FOUND. Using shared default webview.")
324
- webVC = preloaded
325
- } else {
326
- self.log("Preload Check: Loading normally. (Req: \(isDefault ? "default" : "specific route"), Preload Available: \(self.preloadedWebVC != nil))")
327
- webVC = AcmoWebViewController(url: url)
328
- }
259
+ webVC = AcmoWebViewController(url: url)
329
260
 
330
261
  webVC.onDismiss = {
331
262
  webVC.onDismiss = nil
@@ -387,8 +318,6 @@ public class Tyrads : NSObject {
387
318
  self.currentLanguage = lang
388
319
  UserDefaults.standard.set(lang, forKey: "locale")
389
320
  await LocalizationService.shared.changeLanguage(locale: lang)
390
-
391
- self.preloadedWebVC = nil
392
321
  }
393
322
 
394
323
  public func isPrivacyAccepted() -> Bool {
@@ -11,11 +11,11 @@ import CoreTelephony
11
11
 
12
12
  func getDeviceDetails() -> [String: Any] {
13
13
  var fd = [String: Any]()
14
-
14
+
15
15
  let device = UIDevice.current
16
16
  let bundle = Bundle.main
17
17
  let locale = Locale.current
18
-
18
+
19
19
  // device basic info
20
20
  fd["deviceId"] = device.identifierForVendor?.uuidString ?? "Unknown"
21
21
  fd["device"] = device.model.lowercased().contains("ipad") ? "iPad" : "iPhone"
@@ -26,29 +26,31 @@ func getDeviceDetails() -> [String: Any] {
26
26
  fd["releaseVersion"] = device.systemVersion
27
27
  fd["modelName"] = getModelName()
28
28
  fd["hardware"] = deviceIdentifier()
29
-
29
+
30
30
  fd["product"] = "Darwin"
31
31
  fd["platform"] = "iOS"
32
32
  fd["apiVersion"] = AcmoConfig.API_VERSION
33
33
  fd["sdkVersion"] = AcmoConfig.SDK_VERSION
34
34
  fd["sdkPlatform"] = AcmoConfig.SDK_PLATFORM
35
-
35
+
36
36
  // app info
37
37
  fd["version"] = bundle.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
38
38
  fd["build"] = bundle.infoDictionary?["CFBundleVersion"] as? String ?? "Unknown"
39
39
  fd["package"] = bundle.bundleIdentifier ?? "Unknown"
40
40
  fd["installerStore"] = "App Store"
41
-
42
- fd["osLang"] = locale.languageCode ?? "en"
43
-
41
+
42
+ fd["osLang"] = Locale.current.identifier.replacingOccurrences(of: "_", with: "-")
43
+ print("[DeviceDetails] osLang resolved: \(fd["osLang"] as? String ?? "unknown")")
44
+
45
+
44
46
  // security and virtual check
45
47
  fd["rooted"] = isJailBroken()
46
48
  fd["virtual"] = isRunningOnSimulator()
47
-
49
+
48
50
  // storage info
49
51
  let (totalSpace, freeSpace) = getDiskSpace()
50
52
  fd["totalMemory"] = Double(round(100 * (Double(totalSpace) / 1_000_000_000)) / 100)
51
-
53
+
52
54
  // network info
53
55
  fd["connectionType"] = getNetworkType()
54
56
 
@@ -59,7 +61,7 @@ func getNetworkType() -> String {
59
61
  let monitor = NWPathMonitor()
60
62
  let semaphore = DispatchSemaphore(value: 0)
61
63
  var networkType = "No Connection"
62
-
64
+
63
65
  monitor.pathUpdateHandler = { path in
64
66
  if path.status == .satisfied {
65
67
  if path.usesInterfaceType(.wifi) {
@@ -76,23 +78,23 @@ func getNetworkType() -> String {
76
78
  }
77
79
  semaphore.signal()
78
80
  }
79
-
81
+
80
82
  let queue = DispatchQueue(label: "NetworkMonitor")
81
83
  monitor.start(queue: queue)
82
-
84
+
83
85
  _ = semaphore.wait(timeout: .now() + 0.1)
84
86
  monitor.cancel()
85
-
87
+
86
88
  return networkType
87
89
  }
88
90
 
89
91
  func getUptimeMetrics() -> [String: Any] {
90
92
  let uptime = ProcessInfo.processInfo.systemUptime
91
93
  let bootTimeDate = Date(timeIntervalSinceNow: -uptime)
92
-
94
+
93
95
  let formatter = DateFormatter()
94
96
  formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
95
-
97
+
96
98
  return [
97
99
  "device_uptime_hours": String(format: "%.2f", uptime / 3600),
98
100
  "device_boot_time": formatter.string(from: bootTimeDate)
@@ -102,7 +104,7 @@ func getUptimeMetrics() -> [String: Any] {
102
104
  func getCellularType() -> String {
103
105
  let networkInfo = CTTelephonyNetworkInfo()
104
106
  var carrierType = "Cellular"
105
-
107
+
106
108
  if #available(iOS 14.1, *) {
107
109
  if let radioTechnologies = networkInfo.serviceCurrentRadioAccessTechnology {
108
110
  for (_, technology) in radioTechnologies {
@@ -211,7 +213,7 @@ func deviceIdentifier() -> String {
211
213
 
212
214
  func getModelName() -> String {
213
215
  let identifier = deviceIdentifier()
214
-
216
+
215
217
  let iphoneModelMapping: [String: String] = [
216
218
  "iPhone1,1": "iPhone",
217
219
  "iPhone1,2": "iPhone 3G",
package/ios/TyradsSdk.mm CHANGED
@@ -34,9 +34,6 @@ RCT_EXTERN_METHOD(isPrivacyAccepted:(RCTPromiseResolveBlock)resolve
34
34
  rejecter:(RCTPromiseRejectBlock)reject)
35
35
  RCT_EXTERN_METHOD(checkOnboardingProcess:(RCTPromiseResolveBlock)resolve
36
36
  rejecter:(RCTPromiseRejectBlock)reject)
37
- RCT_EXTERN_METHOD(preloadOffers : (NSString *_Nullable)route
38
- resolver : (RCTPromiseResolveBlock)resolve
39
- rejecter : (RCTPromiseRejectBlock)reject)
40
37
 
41
38
  RCT_EXTERN_METHOD(pushRequestPermission:(RCTPromiseResolveBlock)resolve
42
39
  rejecter:(RCTPromiseRejectBlock)reject)
@@ -131,14 +131,6 @@ class TyradsSdk: RCTEventEmitter , APNsNotificationListener{
131
131
  }
132
132
  }
133
133
 
134
- @objc(preloadOffers:resolver:rejecter:)
135
- func preloadOffers(_ route: String?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
136
- Task { @MainActor in
137
- Tyrads.instance.preloadOffers(route: route)
138
- resolve(nil)
139
- }
140
- }
141
-
142
134
  @objc(changeLanguage:resolver:rejecter:)
143
135
  func changeLanguage(_ lang: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
144
136
  Task {
@@ -231,13 +223,14 @@ class TyradsSdk: RCTEventEmitter , APNsNotificationListener{
231
223
  window.frame = frame
232
224
  window.backgroundColor = .clear
233
225
 
226
+ let moduleName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? "TyradsSdkExample"
234
227
  let rootView = PassthroughRootView(
235
228
  bridge: bridge,
236
- moduleName: "TyradsSdkExample",
229
+ moduleName: moduleName,
237
230
  initialProperties: nil
238
231
  )
239
232
 
240
- rootView.backgroundColor = .yellow
233
+ rootView.backgroundColor = .clear
241
234
  rootView.frame = frame
242
235
  let vc = UIViewController()
243
236
  vc.view = rootView
@@ -9,8 +9,8 @@ class AcmoConfig {
9
9
  static BASE_URL = `https://api.tyrads.com/v${this.API_VERSION}/`;
10
10
  static MAJOR_VERSION = "4";
11
11
  static MINOR_VERSION = "0";
12
- static PATCH_VERSION = "0";
13
- static BUILD_VERSION = "1";
12
+ static PATCH_VERSION = "2";
13
+ static BUILD_VERSION = "3";
14
14
  static SDK_PLATFORM = "React Native";
15
15
  static SDK_VERSION = `${this.MAJOR_VERSION}.${this.MINOR_VERSION}.${this.PATCH_VERSION}-${this.BUILD_VERSION}`;
16
16
  }
@@ -5,8 +5,8 @@ export class AcmoConfig {
5
5
  static BASE_URL = `https://api.tyrads.com/v${this.API_VERSION}/`;
6
6
  static MAJOR_VERSION = "4";
7
7
  static MINOR_VERSION = "0";
8
- static PATCH_VERSION = "0";
9
- static BUILD_VERSION = "1";
8
+ static PATCH_VERSION = "2";
9
+ static BUILD_VERSION = "3";
10
10
  static SDK_PLATFORM = "React Native";
11
11
  static SDK_VERSION = `${this.MAJOR_VERSION}.${this.MINOR_VERSION}.${this.PATCH_VERSION}-${this.BUILD_VERSION}`;
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tyrads.com/tyrads-sdk",
3
- "version": "4.0.0",
3
+ "version": "4.0.2-beta.0",
4
4
  "description": "Tyrads SDK for React Native ",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -3,8 +3,8 @@ export class AcmoConfig {
3
3
  public static BASE_URL = `https://api.tyrads.com/v${this.API_VERSION}/`;
4
4
  public static MAJOR_VERSION = "4";
5
5
  public static MINOR_VERSION = "0";
6
- public static PATCH_VERSION = "0";
7
- public static BUILD_VERSION = "1";
6
+ public static PATCH_VERSION = "2";
7
+ public static BUILD_VERSION = "3";
8
8
  public static SDK_PLATFORM = "React Native";
9
9
  public static SDK_VERSION = `${this.MAJOR_VERSION}.${this.MINOR_VERSION}.${this.PATCH_VERSION}-${this.BUILD_VERSION}`;
10
10
  }