@bigcrunch/react-native-ads 0.9.0 → 0.10.1

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.
@@ -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.9.0"
31
+ internal const val SDK_VERSION = "0.10.1"
32
32
 
33
33
  @Volatile
34
34
  private var instance: DeviceContext? = null
@@ -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.9.0"
77
+ static let SDK_VERSION = "0.10.1"
78
78
  let sdkVersion: String = SDK_VERSION
79
79
 
80
80
  /// SDK platform (always "ios")
@@ -67,7 +67,7 @@ class BigCrunchBannerViewWrapper: UIView {
67
67
  }
68
68
  }
69
69
 
70
- var sizeString: String = "BANNER"
70
+ var sizeString: String = "" // Empty = use config sizes (no override)
71
71
  @objc var customWidth: NSNumber? {
72
72
  didSet {
73
73
  _customWidth = customWidth?.intValue
@@ -151,6 +151,13 @@ class BigCrunchBannerViewWrapper: UIView {
151
151
  func updateAdSize() {
152
152
  guard let bannerView = bannerView else { return }
153
153
 
154
+ // If no explicit size was set (sizeString is empty and no custom dimensions),
155
+ // don't set adSizeOverride — let the native SDK use config sizes
156
+ if sizeString.isEmpty && _customWidth == nil && _customHeight == nil {
157
+ bannerView.adSizeOverride = nil
158
+ return
159
+ }
160
+
154
161
  var googleAdSize: GoogleMobileAds.AdSize
155
162
  var bcAdSize: BCAdSize
156
163
 
@@ -1 +1 @@
1
- {"version":3,"file":"BigCrunchBannerView.d.ts","sourceRoot":"","sources":["../src/BigCrunchBannerView.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAkD,MAAM,OAAO,CAAC;AASvE,OAAO,KAAK,EACV,wBAAwB,EAKzB,MAAM,SAAS,CAAC;AAmBjB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA+MlE,CAAC;AAGF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"BigCrunchBannerView.d.ts","sourceRoot":"","sources":["../src/BigCrunchBannerView.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAkD,MAAM,OAAO,CAAC;AASvE,OAAO,KAAK,EACV,wBAAwB,EAKzB,MAAM,SAAS,CAAC;AAmBjB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA6NlE,CAAC;AAGF,eAAe,mBAAmB,CAAC"}
@@ -31,12 +31,18 @@ const NativeBannerView = requireNativeComponent(NATIVE_COMPONENT_NAME);
31
31
  * />
32
32
  * ```
33
33
  */
34
- export const BigCrunchBannerView = ({ placementId, size = 'BANNER', autoLoad = true, refreshInterval = 0, customTargeting, style, onAdLoaded, onAdFailedToLoad, onAdImpression, onAdClicked, onAdOpened, onAdClosed, onAdRevenue, }) => {
34
+ export const BigCrunchBannerView = ({ placementId, size, autoLoad = true, refreshInterval = 0, customTargeting, style, onAdLoaded, onAdFailedToLoad, onAdImpression, onAdClicked, onAdOpened, onAdClosed, onAdRevenue, }) => {
35
35
  const viewRef = useRef(null);
36
36
  const subscriptionsRef = useRef([]);
37
37
  const viewIdRef = useRef(`banner_${placementId}_${Date.now()}`);
38
- // Calculate banner size
38
+ // Calculate banner size for layout
39
+ // When size is undefined, config drives the ad size natively — use adaptive layout
39
40
  const bannerSize = useMemo(() => {
41
+ if (size === undefined) {
42
+ // No explicit size — let backend config drive the ad size
43
+ // Use adaptive layout since config may specify smart/adaptive sizes
44
+ return { width: 0, height: 0, adaptive: true, configDriven: true };
45
+ }
40
46
  if (typeof size === 'object' && 'width' in size && 'height' in size) {
41
47
  // Custom size
42
48
  return size;
@@ -50,8 +56,8 @@ export const BigCrunchBannerView = ({ placementId, size = 'BANNER', autoLoad = t
50
56
  }
51
57
  return dimensions;
52
58
  }
53
- // Default to BANNER size
54
- return BANNER_SIZES.BANNER;
59
+ // Unknown size string — fallback to adaptive layout
60
+ return { width: 0, height: 0, adaptive: true };
55
61
  }, [size]);
56
62
  // Handle native events
57
63
  const handleNativeEvent = useCallback((_eventName, handler) => {
@@ -155,20 +161,28 @@ export const BigCrunchBannerView = ({ placementId, size = 'BANNER', autoLoad = t
155
161
  return StyleSheet.flatten([baseStyle, style]);
156
162
  }, [bannerSize, style]);
157
163
  // Native view props
158
- // Always pass explicit dimensions to the native view
164
+ // Only send size/customWidth/customHeight when explicitly specified by the developer.
165
+ // When omitted, the native SDK uses placement config sizes (e.g., smart/adaptive from backend).
159
166
  const nativeProps = {
160
167
  ref: viewRef,
161
168
  style: containerStyle,
162
169
  placementId,
163
- size: typeof size === 'string' ? size : 'CUSTOM',
164
- // Always pass width and height, even for standard sizes
165
- customWidth: bannerSize.width > 0 ? bannerSize.width : undefined,
166
- customHeight: bannerSize.height > 0 ? bannerSize.height : undefined,
167
170
  autoLoad,
168
171
  refreshInterval,
169
172
  customTargeting,
170
173
  viewId: viewIdRef.current,
171
174
  };
175
+ // Only send size to native when explicitly set by the developer
176
+ if (size !== undefined) {
177
+ if (typeof size === 'string') {
178
+ nativeProps.size = size;
179
+ }
180
+ else if (typeof size === 'object' && 'width' in size && 'height' in size) {
181
+ nativeProps.size = 'CUSTOM';
182
+ nativeProps.customWidth = size.width;
183
+ nativeProps.customHeight = size.height;
184
+ }
185
+ }
172
186
  // Return the native view directly with the container style
173
187
  return React.createElement(NativeBannerView, { ...nativeProps });
174
188
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcrunch/react-native-ads",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
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",
@@ -51,7 +51,7 @@ const NativeBannerView = requireNativeComponent<any>(NATIVE_COMPONENT_NAME);
51
51
  */
52
52
  export const BigCrunchBannerView: React.FC<BigCrunchBannerViewProps> = ({
53
53
  placementId,
54
- size = 'BANNER',
54
+ size,
55
55
  autoLoad = true,
56
56
  refreshInterval = 0,
57
57
  customTargeting,
@@ -68,8 +68,14 @@ export const BigCrunchBannerView: React.FC<BigCrunchBannerViewProps> = ({
68
68
  const subscriptionsRef = useRef<EventSubscription[]>([]);
69
69
  const viewIdRef = useRef<string>(`banner_${placementId}_${Date.now()}`);
70
70
 
71
- // Calculate banner size
71
+ // Calculate banner size for layout
72
+ // When size is undefined, config drives the ad size natively — use adaptive layout
72
73
  const bannerSize = useMemo(() => {
74
+ if (size === undefined) {
75
+ // No explicit size — let backend config drive the ad size
76
+ // Use adaptive layout since config may specify smart/adaptive sizes
77
+ return { width: 0, height: 0, adaptive: true, configDriven: true };
78
+ }
73
79
  if (typeof size === 'object' && 'width' in size && 'height' in size) {
74
80
  // Custom size
75
81
  return size;
@@ -82,8 +88,8 @@ export const BigCrunchBannerView: React.FC<BigCrunchBannerViewProps> = ({
82
88
  }
83
89
  return dimensions;
84
90
  }
85
- // Default to BANNER size
86
- return BANNER_SIZES.BANNER;
91
+ // Unknown size string — fallback to adaptive layout
92
+ return { width: 0, height: 0, adaptive: true };
87
93
  }, [size]);
88
94
 
89
95
  // Handle native events
@@ -239,21 +245,29 @@ export const BigCrunchBannerView: React.FC<BigCrunchBannerViewProps> = ({
239
245
  }, [bannerSize, style]);
240
246
 
241
247
  // Native view props
242
- // Always pass explicit dimensions to the native view
243
- const nativeProps = {
248
+ // Only send size/customWidth/customHeight when explicitly specified by the developer.
249
+ // When omitted, the native SDK uses placement config sizes (e.g., smart/adaptive from backend).
250
+ const nativeProps: any = {
244
251
  ref: viewRef,
245
252
  style: containerStyle,
246
253
  placementId,
247
- size: typeof size === 'string' ? size : 'CUSTOM',
248
- // Always pass width and height, even for standard sizes
249
- customWidth: bannerSize.width > 0 ? bannerSize.width : undefined,
250
- customHeight: bannerSize.height > 0 ? bannerSize.height : undefined,
251
254
  autoLoad,
252
255
  refreshInterval,
253
256
  customTargeting,
254
257
  viewId: viewIdRef.current,
255
258
  };
256
259
 
260
+ // Only send size to native when explicitly set by the developer
261
+ if (size !== undefined) {
262
+ if (typeof size === 'string') {
263
+ nativeProps.size = size;
264
+ } else if (typeof size === 'object' && 'width' in size && 'height' in size) {
265
+ nativeProps.size = 'CUSTOM';
266
+ nativeProps.customWidth = size.width;
267
+ nativeProps.customHeight = size.height;
268
+ }
269
+ }
270
+
257
271
  // Return the native view directly with the container style
258
272
  return <NativeBannerView {...nativeProps} />;
259
273
  };