@bigcrunch/react-native-ads 0.4.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.
Files changed (58) hide show
  1. package/README.md +5 -5
  2. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchAds.kt +434 -0
  3. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchBannerView.kt +484 -0
  4. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchInterstitial.kt +403 -0
  5. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchRewarded.kt +409 -0
  6. package/android/bigcrunch-ads/com/bigcrunch/ads/adapters/GoogleAdsAdapter.kt +592 -0
  7. package/android/bigcrunch-ads/com/bigcrunch/ads/core/AdOrchestrator.kt +623 -0
  8. package/android/bigcrunch-ads/com/bigcrunch/ads/core/AnalyticsClient.kt +719 -0
  9. package/android/bigcrunch-ads/com/bigcrunch/ads/core/BidRequestClient.kt +364 -0
  10. package/android/bigcrunch-ads/com/bigcrunch/ads/core/ConfigManager.kt +300 -0
  11. package/android/bigcrunch-ads/com/bigcrunch/ads/core/DeviceContext.kt +385 -0
  12. package/android/bigcrunch-ads/com/bigcrunch/ads/core/RewardedCallback.kt +42 -0
  13. package/android/bigcrunch-ads/com/bigcrunch/ads/core/SessionManager.kt +330 -0
  14. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/DeviceHelper.kt +60 -0
  15. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/HttpClient.kt +114 -0
  16. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/Logger.kt +71 -0
  17. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/PrivacyStore.kt +125 -0
  18. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/Storage.kt +88 -0
  19. package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/BannerAdListener.kt +55 -0
  20. package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/InterstitialAdListener.kt +55 -0
  21. package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/RewardedAdListener.kt +58 -0
  22. package/android/bigcrunch-ads/com/bigcrunch/ads/models/AdEvent.kt +880 -0
  23. package/android/bigcrunch-ads/com/bigcrunch/ads/models/AppConfig.kt +87 -0
  24. package/android/bigcrunch-ads/com/bigcrunch/ads/models/DeviceData.kt +18 -0
  25. package/android/bigcrunch-ads/com/bigcrunch/ads/models/PlacementConfig.kt +70 -0
  26. package/android/bigcrunch-ads/com/bigcrunch/ads/models/SessionInfo.kt +21 -0
  27. package/android/build.gradle +22 -10
  28. package/android/settings.gradle +2 -6
  29. package/android/src/main/java/com/bigcrunch/ads/react/BigCrunchAdsModule.kt +8 -2
  30. package/ios/BigCrunchAds/Sources/Adapters/GoogleAdsAdapter.swift +512 -0
  31. package/ios/BigCrunchAds/Sources/BigCrunchAds.swift +387 -0
  32. package/ios/BigCrunchAds/Sources/BigCrunchBannerView.swift +448 -0
  33. package/ios/BigCrunchAds/Sources/BigCrunchInterstitial.swift +412 -0
  34. package/ios/BigCrunchAds/Sources/BigCrunchRewarded.swift +523 -0
  35. package/ios/BigCrunchAds/Sources/Core/AdOrchestrator.swift +514 -0
  36. package/ios/BigCrunchAds/Sources/Core/AnalyticsClient.swift +874 -0
  37. package/ios/BigCrunchAds/Sources/Core/BidRequestClient.swift +344 -0
  38. package/ios/BigCrunchAds/Sources/Core/ConfigManager.swift +305 -0
  39. package/ios/BigCrunchAds/Sources/Core/DeviceContext.swift +284 -0
  40. package/ios/BigCrunchAds/Sources/Core/SessionManager.swift +392 -0
  41. package/ios/BigCrunchAds/Sources/Internal/HTTPClient.swift +146 -0
  42. package/ios/BigCrunchAds/Sources/Internal/Logger.swift +62 -0
  43. package/ios/BigCrunchAds/Sources/Internal/PrivacyStore.swift +129 -0
  44. package/ios/BigCrunchAds/Sources/Internal/Storage.swift +73 -0
  45. package/ios/BigCrunchAds/Sources/Models/AdEvent.swift +784 -0
  46. package/ios/BigCrunchAds/Sources/Models/AppConfig.swift +97 -0
  47. package/ios/BigCrunchAds/Sources/Models/DeviceData.swift +68 -0
  48. package/ios/BigCrunchAds/Sources/Models/PlacementConfig.swift +137 -0
  49. package/ios/BigCrunchAds/Sources/Models/SessionInfo.swift +48 -0
  50. package/ios/BigCrunchAdsModule.swift +37 -9
  51. package/ios/BigCrunchBannerViewManager.swift +0 -1
  52. package/lib/index.d.ts +1 -1
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/index.js +3 -2
  55. package/package.json +7 -1
  56. package/react-native-bigcrunch-ads.podspec +0 -1
  57. package/scripts/inject-version.js +55 -0
  58. package/src/index.ts +3 -2
@@ -0,0 +1,87 @@
1
+ package com.bigcrunch.ads.models
2
+
3
+ import com.squareup.moshi.Json
4
+ import com.squareup.moshi.JsonClass
5
+
6
+ /**
7
+ * Top-level application configuration returned from the BigCrunch backend
8
+ *
9
+ * This config contains all placement definitions and is fetched once at SDK initialization
10
+ * and cached for subsequent sessions.
11
+ */
12
+ @JsonClass(generateAdapter = true)
13
+ data class AppConfig(
14
+ @Json(name = "propertyId")
15
+ val propertyId: String,
16
+
17
+ @Json(name = "appName")
18
+ val appName: String,
19
+
20
+ @Json(name = "gamNetworkCode")
21
+ val gamNetworkCode: String,
22
+
23
+ @Json(name = "s2s")
24
+ val s2s: S2SConfig,
25
+
26
+ @Json(name = "bidders")
27
+ val bidders: Map<String, BidderEntry>? = null,
28
+
29
+ @Json(name = "amazonAps")
30
+ val amazonAps: GlobalAmazonConfig? = null,
31
+
32
+ @Json(name = "useTestAds")
33
+ val useTestAds: Boolean = false,
34
+
35
+ @Json(name = "refresh")
36
+ val refresh: RefreshConfig? = null,
37
+
38
+ @Json(name = "placements")
39
+ val placements: List<PlacementConfig>
40
+ )
41
+
42
+ /**
43
+ * S2S (server-to-server) auction configuration
44
+ *
45
+ * Controls the connection to the BigCrunch S2S endpoint for bid requests.
46
+ */
47
+ @JsonClass(generateAdapter = true)
48
+ data class S2SConfig(
49
+ @Json(name = "enabled")
50
+ val enabled: Boolean = true,
51
+
52
+ @Json(name = "serverUrl")
53
+ val serverUrl: String,
54
+
55
+ @Json(name = "timeoutMs")
56
+ val timeoutMs: Int
57
+ )
58
+
59
+ /**
60
+ * Top-level bidder entry with shared params and per-placement params
61
+ *
62
+ * Each bidder has optional shared params (applied to all impressions) and
63
+ * a placements map (placementId → imp-level params for that bidder).
64
+ */
65
+ @JsonClass(generateAdapter = true)
66
+ data class BidderEntry(
67
+ @Json(name = "params")
68
+ val params: Map<String, Any>? = null,
69
+
70
+ @Json(name = "placements")
71
+ val placements: Map<String, Map<String, Any>>? = null
72
+ )
73
+
74
+ /**
75
+ * Global Amazon APS configuration
76
+ */
77
+ @JsonClass(generateAdapter = true)
78
+ data class GlobalAmazonConfig(
79
+ @Json(name = "enabled")
80
+ val enabled: Boolean,
81
+
82
+ @Json(name = "pubId")
83
+ val pubId: String,
84
+
85
+ @Json(name = "timeout")
86
+ val timeout: Int
87
+ )
@@ -0,0 +1,18 @@
1
+ package com.bigcrunch.ads.models
2
+
3
+ /**
4
+ * Device information for analytics and targeting
5
+ */
6
+ data class DeviceData(
7
+ val deviceId: String,
8
+ val deviceModel: String,
9
+ val osVersion: String,
10
+ val appVersion: String,
11
+ val screenWidth: Int,
12
+ val screenHeight: Int,
13
+ val language: String,
14
+ val country: String,
15
+ val carrier: String?,
16
+ val networkType: String?,
17
+ val isTablet: Boolean
18
+ )
@@ -0,0 +1,70 @@
1
+ package com.bigcrunch.ads.models
2
+
3
+ import com.squareup.moshi.Json
4
+ import com.squareup.moshi.JsonClass
5
+
6
+ /**
7
+ * Configuration for a single ad placement
8
+ *
9
+ * Contains all information needed to request and display an ad at a specific
10
+ * location in the app. Bidder configuration is no longer stored here — it lives
11
+ * in the top-level [AppConfig.bidders] dictionary.
12
+ */
13
+ @JsonClass(generateAdapter = true)
14
+ data class PlacementConfig(
15
+ @Json(name = "placementId")
16
+ val placementId: String,
17
+
18
+ @Json(name = "format")
19
+ val format: String, // "banner", "interstitial", "rewarded"
20
+
21
+ @Json(name = "gamAdUnit")
22
+ val gamAdUnit: String,
23
+
24
+ @Json(name = "sizes")
25
+ val sizes: List<AdSize>? = null,
26
+
27
+ @Json(name = "refresh")
28
+ val refresh: RefreshConfig? = null
29
+ )
30
+
31
+ /**
32
+ * Ad size dimensions
33
+ *
34
+ * When [type] is "adaptive" or "smart", the SDK will use Google's adaptive
35
+ * banner API to calculate the optimal height for the given [width].
36
+ * A [width] of 0 means "use screen width".
37
+ */
38
+ @JsonClass(generateAdapter = true)
39
+ data class AdSize(
40
+ @Json(name = "width")
41
+ val width: Int,
42
+
43
+ @Json(name = "height")
44
+ val height: Int,
45
+
46
+ @Json(name = "type")
47
+ val type: String? = null
48
+ ) {
49
+ val isAdaptive: Boolean
50
+ get() = type == "adaptive" || type == "smart"
51
+
52
+ companion object {
53
+ fun adaptive(width: Int = 0): AdSize = AdSize(width = width, height = 0, type = "adaptive")
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Refresh configuration for banner ads
59
+ */
60
+ @JsonClass(generateAdapter = true)
61
+ data class RefreshConfig(
62
+ @Json(name = "enabled")
63
+ val enabled: Boolean,
64
+
65
+ @Json(name = "intervalMs")
66
+ val intervalMs: Int,
67
+
68
+ @Json(name = "maxRefreshes")
69
+ val maxRefreshes: Int
70
+ )
@@ -0,0 +1,21 @@
1
+ package com.bigcrunch.ads.models
2
+
3
+ /**
4
+ * Data class containing information about the current app session.
5
+ * Used for analytics and tracking user engagement.
6
+ *
7
+ * @property sessionId Unique identifier for this session
8
+ * @property startTime ISO 8601 timestamp when the session started
9
+ * @property screenViewCount Number of screens viewed in this session
10
+ * @property adRequestCount Number of ad requests made in this session
11
+ * @property adImpressionCount Number of ad impressions in this session
12
+ * @property totalRevenueMicros Total ad revenue generated in this session (in micros)
13
+ */
14
+ data class SessionInfo(
15
+ val sessionId: String,
16
+ val startTime: String,
17
+ val screenViewCount: Int,
18
+ val adRequestCount: Int,
19
+ val adImpressionCount: Int,
20
+ val totalRevenueMicros: Long = 0L
21
+ )
@@ -14,11 +14,15 @@ buildscript {
14
14
 
15
15
  apply plugin: 'com.android.library'
16
16
  apply plugin: 'kotlin-android'
17
+ apply plugin: 'kotlin-kapt'
17
18
 
18
19
  def safeExtGet(prop, fallback) {
19
20
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20
21
  }
21
22
 
23
+ def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
24
+ def packageVersion = packageJson.version
25
+
22
26
  android {
23
27
  compileSdkVersion safeExtGet('compileSdkVersion', 34)
24
28
  namespace 'com.bigcrunch.ads.react'
@@ -27,7 +31,7 @@ android {
27
31
  minSdkVersion safeExtGet('minSdkVersion', 21)
28
32
  targetSdkVersion safeExtGet('targetSdkVersion', 34)
29
33
  versionCode 1
30
- versionName "0.1.0"
34
+ versionName packageVersion
31
35
  }
32
36
 
33
37
  buildTypes {
@@ -45,6 +49,12 @@ android {
45
49
  jvmTarget = '11'
46
50
  freeCompilerArgs += ['-Xskip-metadata-version-check']
47
51
  }
52
+
53
+ sourceSets {
54
+ main {
55
+ java.srcDirs += 'bigcrunch-ads'
56
+ }
57
+ }
48
58
  }
49
59
 
50
60
  repositories {
@@ -59,16 +69,18 @@ dependencies {
59
69
  // React Native dependency
60
70
  implementation 'com.facebook.react:react-native:+'
61
71
 
62
- // Native Android SDK dependency
63
- // This includes all required dependencies (Google Ads, Prebid, OkHttp, Moshi)
64
- // as transitive dependencies, eliminating the need for duplication
65
- implementation project(':bigcrunch-ads')
72
+ // Google Mobile Ads SDK (Ad Manager)
73
+ implementation 'com.google.android.gms:play-services-ads:22.6.0'
74
+
75
+ // Networking
76
+ implementation 'com.squareup.okhttp3:okhttp:4.11.0'
66
77
 
67
- // Google Ads SDK - needed at compile time for AdSize reference in BigCrunchBannerViewManager
68
- // (main SDK uses 'implementation' so it's not transitively available)
69
- compileOnly 'com.google.android.gms:play-services-ads:22.6.0'
78
+ // JSON parsing (Moshi)
79
+ implementation 'com.squareup.moshi:moshi:1.14.0'
80
+ implementation 'com.squareup.moshi:moshi-kotlin:1.14.0'
81
+ kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.14.0'
70
82
 
71
- // Coroutines - needed by React Native bridge code
72
- // (Native SDK uses 'implementation' so not automatically transitive)
83
+ // Coroutines
73
84
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
85
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
74
86
  }
@@ -1,6 +1,2 @@
1
- // Include the native Android SDK module from the parent directory
2
- // This allows the React Native Android module to depend on the native SDK
3
- // and eliminates code duplication
4
-
5
- include ':bigcrunch-ads'
6
- project(':bigcrunch-ads').projectDir = new File(rootProject.projectDir, '../../android/bigcrunch-ads')
1
+ // Native Android SDK sources are bundled directly into this module.
2
+ // No external project dependency needed.
@@ -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)