@bigcrunch/react-native-ads 0.5.0 → 0.6.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.
@@ -50,7 +50,6 @@ internal class ConfigManager(
50
50
  return AppConfig(
51
51
  propertyId = propertyId,
52
52
  appName = "Mock Test App",
53
- environment = "test",
54
53
  gamNetworkCode = "", // Empty for AdMob sample ads
55
54
  s2s = com.bigcrunch.ads.models.S2SConfig(
56
55
  serverUrl = "https://s2s.bigcrunch.com/auction",
@@ -28,7 +28,7 @@ internal class DeviceContext private constructor(context: Context) {
28
28
 
29
29
  companion object {
30
30
  private const val TAG = "DeviceContext"
31
- internal const val SDK_VERSION = "0.5.0"
31
+ internal const val SDK_VERSION = "0.6.0"
32
32
 
33
33
  @Volatile
34
34
  private var instance: DeviceContext? = null
@@ -17,9 +17,6 @@ data class AppConfig(
17
17
  @Json(name = "appName")
18
18
  val appName: String,
19
19
 
20
- @Json(name = "environment")
21
- val environment: String,
22
-
23
20
  @Json(name = "gamNetworkCode")
24
21
  val gamNetworkCode: String,
25
22
 
@@ -54,8 +54,14 @@ class BigCrunchAdsModule(reactContext: ReactApplicationContext) :
54
54
  BigCrunchAds.setDebugMode(true)
55
55
  }
56
56
 
57
- // SDK initialization is complete
58
- // The Android SDK now handles config loading internally
57
+ // Wait for config to be loaded before resolving the promise
58
+ // This ensures placements are available when the app starts loading ads
59
+ val configLoaded = BigCrunchAds.waitForConfig()
60
+ if (!configLoaded) {
61
+ promise.reject("INIT_ERROR", "Failed to load configuration", null)
62
+ return@launch
63
+ }
64
+
59
65
  promise.resolve(null)
60
66
  } catch (e: Exception) {
61
67
  promise.reject("INIT_ERROR", "Failed to initialize SDK: ${e.message}", e)
@@ -44,7 +44,6 @@ internal class ConfigManager {
44
44
  return AppConfig(
45
45
  propertyId: propertyId,
46
46
  appName: "Mock Test App",
47
- environment: "test",
48
47
  gamNetworkCode: "", // Empty for AdMob sample ads
49
48
  s2s: S2SConfig(
50
49
  serverUrl: "https://s2s.bigcrunch.com/auction",
@@ -74,7 +74,7 @@ internal final class DeviceContext {
74
74
  // MARK: - SDK Properties
75
75
 
76
76
  /// SDK version
77
- static let SDK_VERSION = "0.5.0"
77
+ static let SDK_VERSION = "0.6.0"
78
78
  let sdkVersion: String = SDK_VERSION
79
79
 
80
80
  /// SDK platform (always "ios")
@@ -9,7 +9,6 @@ import Foundation
9
9
  public struct AppConfig: Codable {
10
10
  public let propertyId: String
11
11
  public let appName: String
12
- public let environment: String
13
12
  public let gamNetworkCode: String
14
13
  public let s2s: S2SConfig
15
14
  public let bidders: [String: BidderEntry]?
@@ -21,7 +20,6 @@ public struct AppConfig: Codable {
21
20
  public init(
22
21
  propertyId: String,
23
22
  appName: String,
24
- environment: String,
25
23
  gamNetworkCode: String,
26
24
  s2s: S2SConfig,
27
25
  bidders: [String: BidderEntry]? = nil,
@@ -32,7 +30,6 @@ public struct AppConfig: Codable {
32
30
  ) {
33
31
  self.propertyId = propertyId
34
32
  self.appName = appName
35
- self.environment = environment
36
33
  self.gamNetworkCode = gamNetworkCode
37
34
  self.s2s = s2s
38
35
  self.bidders = bidders
@@ -120,6 +120,26 @@ class RewardedDelegate: NSObject, BigCrunchRewardedDelegate {
120
120
  }
121
121
  }
122
122
 
123
+ // MARK: - Initialization Callback Bridge
124
+
125
+ class InitCallbackBridge: NSObject, BigCrunchInitializationCallback {
126
+ private let onSuccess: () -> Void
127
+ private let onFailure: (String) -> Void
128
+
129
+ init(onSuccess: @escaping () -> Void, onFailure: @escaping (String) -> Void) {
130
+ self.onSuccess = onSuccess
131
+ self.onFailure = onFailure
132
+ }
133
+
134
+ func onInitialized() {
135
+ onSuccess()
136
+ }
137
+
138
+ func onInitializationFailed(error: String) {
139
+ onFailure(error)
140
+ }
141
+ }
142
+
123
143
  @objc(BigCrunchAdsModule)
124
144
  class BigCrunchAdsModule: RCTEventEmitter {
125
145
 
@@ -129,6 +149,7 @@ class BigCrunchAdsModule: RCTEventEmitter {
129
149
  var rewardedCache: [String: Any] = [:]
130
150
  private var interstitialDelegates: [String: InterstitialDelegate] = [:]
131
151
  var rewardedDelegates: [String: RewardedDelegate] = [:]
152
+ private var initCallbackBridge: InitCallbackBridge?
132
153
 
133
154
  override static func moduleName() -> String! {
134
155
  return "BigCrunchAdsModule"
@@ -208,17 +229,26 @@ class BigCrunchAdsModule: RCTEventEmitter {
208
229
  // Map environment strings to SDK enum - "sandbox" maps to .staging
209
230
  let env: BigCrunchEnv = environment == "sandbox" ? .staging : .prod
210
231
 
232
+ // Use callback to wait for config to load before resolving the promise
233
+ // This ensures placements are available when the app starts loading ads
234
+ let callbackBridge = InitCallbackBridge(
235
+ onSuccess: {
236
+ BigCrunchAdsModule.isSDKInitialized = true
237
+ resolver(nil)
238
+ },
239
+ onFailure: { error in
240
+ rejecter("INIT_ERROR", "Failed to load configuration: \(error)", nil)
241
+ }
242
+ )
243
+ // Store strong reference so it isn't deallocated before callback fires
244
+ self.initCallbackBridge = callbackBridge
245
+
211
246
  BigCrunchAds.initialize(
212
247
  propertyId: propertyId,
213
248
  env: env,
214
- useMockConfig: useMockConfig
249
+ useMockConfig: useMockConfig,
250
+ callback: callbackBridge
215
251
  )
216
-
217
- // Track that we've initialized
218
- BigCrunchAdsModule.isSDKInitialized = true
219
-
220
- // Note: debug mode is handled by SDK based on env (.staging enables verbose logging)
221
- resolver(nil)
222
252
  }
223
253
  }
224
254
 
@@ -254,7 +284,6 @@ class BigCrunchAdsModule: RCTEventEmitter {
254
284
  let configDict: [String: Any] = [
255
285
  "propertyId": config.propertyId,
256
286
  "appName": config.appName,
257
- "environment": config.environment,
258
287
  "gamNetworkCode": config.gamNetworkCode,
259
288
  "s2s": [
260
289
  "enabled": config.s2s.enabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcrunch/react-native-ads",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "BigCrunch Mobile Ads SDK for React Native - Simplified in-app advertising with S2S demand and Google Ad Manager",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -92,4 +92,4 @@
92
92
  "optional": false
93
93
  }
94
94
  }
95
- }
95
+ }