@sellwild/react-native-sdk 1.7.2 → 1.7.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellwild/react-native-sdk",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "Sellwild mobile advertising SDK for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import { Platform, requireNativeComponent, UIManager, ViewStyle, View, Text, StyleSheet, NativeSyntheticEvent } from 'react-native'
3
3
  import { resolveAdStack, type SellwildConfig, type AdSize } from '@sellwild/sdk-core'
4
+ import { resolveAppIdentity } from './appIdentity'
4
5
 
5
6
  // Standard IAB mobile ad sizes — used to lock the host View dimensions.
6
7
  // The actual ad size is also propagated to native as the `size` prop label.
@@ -162,10 +163,13 @@ export function SellwildBanner({
162
163
  // of SellwildConfig is ignored on the native side. Note: TS core uses
163
164
  // `adRefreshInterval` (millis); the native side reads it as
164
165
  // `adRefreshIntervalMs`. The bridge translates.
166
+ // App identity is resolved per-platform here (iOS vs Android) from the raw
167
+ // CDN payload on `config.remote`; the native banner path reads these fields.
168
+ const { appBundleId, appStoreUrl } = resolveAppIdentity(config)
165
169
  const nativeConfig = {
166
170
  partnerCode: config.partnerCode,
167
- appBundleId: config.appBundleId,
168
- appStoreUrl: config.appStoreUrl,
171
+ appBundleId,
172
+ appStoreUrl,
169
173
  geo: config.geo,
170
174
  gamTag: config.gamTag,
171
175
  debug: config.debug,
@@ -11,6 +11,7 @@ import {
11
11
  NativeSyntheticEvent,
12
12
  } from 'react-native'
13
13
  import type { SellwildConfig, SellwildListing } from '@sellwild/sdk-core'
14
+ import { resolveAppIdentity } from './appIdentity'
14
15
 
15
16
  // ─── Native component bridge ─────────────────────────────────────────────────
16
17
  //
@@ -161,11 +162,14 @@ export function SellwildFeed({
161
162
  //
162
163
  // Note: TS core uses `adRefreshInterval` (ms); the native side
163
164
  // reads it as `adRefreshIntervalMs`. The bridge translates.
165
+ // App identity is resolved per-platform here (iOS vs Android) from the raw
166
+ // CDN payload on `config.remote`; both native bridges read these fields.
167
+ const { appBundleId, appStoreUrl } = resolveAppIdentity(config)
164
168
  const nativeConfig: Record<string, unknown> = {
165
169
  partnerCode: config.partnerCode,
166
170
  slug: config.slug,
167
- appBundleId: config.appBundleId,
168
- appStoreUrl: config.appStoreUrl,
171
+ appBundleId,
172
+ appStoreUrl,
169
173
  geo: config.geo,
170
174
  gamTag: config.gamTag,
171
175
  debug: config.debug,
@@ -0,0 +1,40 @@
1
+ import { Platform } from 'react-native'
2
+ import type { SellwildConfig } from '@sellwild/sdk-core'
3
+
4
+ /**
5
+ * Resolve per-platform app identity for the native bridge.
6
+ *
7
+ * The CMS may carry OS-specific overrides (`APP_BUNDLE_ID_IOS`/`_ANDROID`,
8
+ * `APP_STORE_URL_IOS`/`_ANDROID`) alongside the shared `APP_BUNDLE_ID` /
9
+ * `APP_STORE_URL`. `core`'s `mapRemoteConfig` maps only the shared
10
+ * (OS-agnostic) keys onto `appBundleId`/`appStoreUrl` and stashes the raw
11
+ * payload on `config.remote`; the platform is only known here on the device,
12
+ * so we resolve the OS-specific value at the bridge boundary — the RN analog
13
+ * of the native `SellwildSDK.apply()` (iOS/Android) and Flutter `dart:io`
14
+ * resolution.
15
+ *
16
+ * Both native bridges (feed + banner) consume `config.appBundleId` /
17
+ * `config.appStoreUrl`, so resolving once here makes both correct without any
18
+ * Kotlin/Swift bridge change.
19
+ *
20
+ * Precedence (matches iOS/Android `apply()` and Flutter): the per-platform CDN
21
+ * value, else the shared `appBundleId`/`appStoreUrl` (which already carries any
22
+ * host override). Backward compatible: no suffixed key = today's behavior.
23
+ */
24
+ export function resolveAppIdentity(config: SellwildConfig): {
25
+ appBundleId?: string
26
+ appStoreUrl?: string
27
+ } {
28
+ const remote = (config.remote ?? {}) as Record<string, unknown>
29
+ const isAndroid = Platform.OS === 'android'
30
+ const pick = (androidKey: string, iosKey: string): string | undefined => {
31
+ const v = remote[isAndroid ? androidKey : iosKey]
32
+ return typeof v === 'string' && v !== '' ? v : undefined
33
+ }
34
+ return {
35
+ appBundleId:
36
+ pick('APP_BUNDLE_ID_ANDROID', 'APP_BUNDLE_ID_IOS') ?? config.appBundleId,
37
+ appStoreUrl:
38
+ pick('APP_STORE_URL_ANDROID', 'APP_STORE_URL_IOS') ?? config.appStoreUrl,
39
+ }
40
+ }