@rediads/react-native-ads 0.1.0-beta.1 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0-beta.1 (not published yet)
3
+ ## 0.1.0 (24 Nov 2026)
4
+
5
+ The first release without "beta".
6
+
7
+ - Native SDK: iOS pods `RediadsDisplay` and `RediadsOM` 0.1.4, Android
8
+ `com.rediads:rediads-display:0.1.1`. Their changes since the betas' 0.1.3 / 0.1.0-beta1 include banner
9
+ viewability on iOS 27 inside a ScrollView, a dead WebView renderer no longer closing the app on
10
+ Android, faster first loads after `start`, and Android 10 as the minimum.
11
+ - Android SDK 0.1.1, not 0.1.0: in 0.1.0 a banner whose refresh failed to render (often the first
12
+ refresh after launch) emptied the slot for good. Now the shown ad stays until the new one has
13
+ rendered, and the banner keeps its size.
14
+ - `RediadsInterstitial` and `RediadsRewarded`: a listener that throws no longer stops the other
15
+ listeners or reaches the native event callback, where it closed a release build; the error goes to
16
+ `console.error`.
17
+ - iOS: loading an ad again under its ID (the same object's `load()`) lets go of the old ad first, as
18
+ Android does, so none of the old ad's events (a late `loaded`, the `dismissed` of one on screen) reach
19
+ JavaScript as the new ad's.
20
+ - Below Android 10 the Android SDK (since 0.1.0) answers every call with "Android 10 or newer is needed ..."
21
+ (`UNSUPPORTED_OS`) and stays off; the bridge passes the error on unchanged (README).
22
+ - Config plugin: helpers the AdMob and GAM plugins use to share Google's app IDs with
23
+ react-native-google-mobile-ads's plugin.
24
+
25
+ ## 0.1.0-beta.1 (17 Nov 2026)
4
26
 
5
27
  - First beta: `RediadsAds.start`, `RediadsBanner` (320x50, 300x250; display, video or both),
6
28
  `RediadsInterstitial` and `RediadsRewarded` with events, and `RediadsAds.whenStarted()` for the
package/README.md CHANGED
@@ -19,12 +19,14 @@ Optional packages, same version as this one:
19
19
  - `@rediads/react-native-ads-admob`: Rediads bids in AdMob mediation.
20
20
  - `@rediads/react-native-ads-gam`: Rediads bids in Google Ad Manager.
21
21
 
22
- This is a **beta** (`0.1.0-beta.1`): install it with the `beta` tag.
23
-
24
22
  ## Requirements
25
23
 
26
24
  - Expo SDK 58 or later (React Native 0.88): an Expo app, or a bare React Native app with Expo modules.
27
- - iOS 16.4 or later, Android 7.0 (API 24) or later.
25
+ - iOS 16.4 or later. Supported: Android 10+ (builds with minSdk 24; ads stay off below Android 10).
26
+ Below Android 10, `start`, every load and every banner answer with the error "Android 10 or newer is
27
+ needed (this device runs API N); the Rediads SDK stays off." (the Android SDK's `UNSUPPORTED_OS`),
28
+ without a request; in the AdMob and GAM packages it comes as the `bid` event's error and Google's ad
29
+ still loads. Nothing to fix in the app.
28
30
  - A **development build**. The package has native code, so it doesn't run in Expo Go. In Expo Go and on
29
31
  web the API still works, but every ad fails and banners render nothing, so the app's no-ad path runs
30
32
  (`RediadsAds.isAvailable` is false).
@@ -36,7 +38,7 @@ This is a **beta** (`0.1.0-beta.1`): install it with the `beta` tag.
36
38
  1. Add the package:
37
39
 
38
40
  ```sh
39
- npm install @rediads/react-native-ads@beta
41
+ npm install @rediads/react-native-ads
40
42
  ```
41
43
 
42
44
  2. Add its config plugin to `app.json` (or `app.config.ts`):
@@ -52,6 +54,10 @@ This is a **beta** (`0.1.0-beta.1`): install it with the `beta` tag.
52
54
  3. Make a development build: `npx expo prebuild --clean`, then `npx expo run:ios` and
53
55
  `npx expo run:android`, or `eas build --profile development`.
54
56
 
57
+ Moving up from an earlier version: if `pod install` says no spec source has the new Rediads pod
58
+ version, run `cd ios && pod install --repo-update` once. CocoaPods keeps a local copy of Rediads'
59
+ pod list and only refreshes it when asked.
60
+
55
61
  What the plugin does during prebuild:
56
62
  - **iOS:** the Rediads SDK pods are binaries in Rediads' pod list. The plugin adds it to the top of
57
63
  `ios/Podfile`, followed by CocoaPods' own list (once a Podfile names a source, CocoaPods uses only
@@ -72,7 +78,7 @@ Config plugins only run in Expo's prebuild, so a bare app does by hand what the
72
78
  1. Add Expo modules support, if the app doesn't have it: `npx install-expo-modules@latest` (see
73
79
  [Expo's guide](https://docs.expo.dev/bare/installing-expo-modules/)). The package needs Expo SDK 58
74
80
  or later.
75
- 2. Add the package: `npm install @rediads/react-native-ads@beta`.
81
+ 2. Add the package: `npm install @rediads/react-native-ads`.
76
82
  3. **iOS:** add the two `source` lines above to the top of `ios/Podfile` (before `platform :ios`),
77
83
  then `cd ios && pod install`. If CocoaPods fails with `Unicode Normalization not appropriate for
78
84
  ASCII-8BIT`, run `export LANG=en_US.UTF-8` first.
@@ -85,8 +91,8 @@ Config plugins only run in Expo's prebuild, so a bare app does by hand what the
85
91
  - The JavaScript API, compiled, with TypeScript types.
86
92
  - The native bridge as source (Swift and Kotlin), compiled into your app with the rest of its Expo
87
93
  modules.
88
- - The Rediads SDK as binaries: on iOS the pods `RediadsDisplay` and `RediadsOM` 0.1.3 (they bring
89
- `RediadsCore` and `RediadsEngine`), on Android `com.rediads:rediads-display:0.1.0-beta1`.
94
+ - The Rediads SDK as binaries: on iOS the pods `RediadsDisplay` and `RediadsOM` 0.1.4 (they bring
95
+ `RediadsCore` and `RediadsEngine`), on Android `com.rediads:rediads-display:0.1.1`.
90
96
 
91
97
  ## Usage
92
98
 
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'com.rediads.reactnative'
7
- version = '0.1.0-beta.1'
7
+ version = '0.1.0'
8
8
 
9
9
  android {
10
10
  namespace "com.rediads.reactnative"
11
11
  defaultConfig {
12
12
  versionCode 1
13
- versionName "0.1.0-beta.1"
13
+ versionName "0.1.0"
14
14
  }
15
15
  lintOptions {
16
16
  abortOnError false
@@ -20,5 +20,5 @@ android {
20
20
  dependencies {
21
21
  // The Rediads SDK, from Maven Central. With the config plugin's androidMavenRepo option, the same
22
22
  // version can come from a local Maven folder instead (SDK development).
23
- implementation 'com.rediads:rediads-display:0.1.0-beta1'
23
+ implementation 'com.rediads:rediads-display:0.1.1'
24
24
  }
@@ -11,7 +11,7 @@ export const RediadsAds = {
11
11
  /** The Rediads auction endpoint, used when `start` gets no `serverUrl`. */
12
12
  DEFAULT_SERVER_URL,
13
13
  /** This package's version; the native SDKs report theirs in `sdkVersion`. */
14
- PACKAGE_VERSION: '0.1.0-beta.1',
14
+ PACKAGE_VERSION: '0.1.0',
15
15
  /**
16
16
  * False in Expo Go, on web and in builds made before this package was added. Then `start` and every
17
17
  * load resolve with an error and banners render nothing, so the app's no-ad path runs.
@@ -86,8 +86,16 @@ class FullScreenAd {
86
86
  }
87
87
  /** @internal */
88
88
  emit(event) {
89
- for (const listener of [...this.listeners])
90
- listener(event);
89
+ // A listener that throws must not stop the others, nor reach the native event callback: an uncaught
90
+ // error there closes a release build.
91
+ for (const listener of [...this.listeners]) {
92
+ try {
93
+ listener(event);
94
+ }
95
+ catch (error) {
96
+ console.error('[Rediads] An ad listener threw:', error);
97
+ }
98
+ }
91
99
  }
92
100
  }
93
101
  /**
@@ -19,9 +19,9 @@ Pod::Spec.new do |s|
19
19
  # The Rediads SDK, a binary pod from Rediads' pod list (github.com/rediads-hq/rediads-ios). The
20
20
  # config plugin (app.plugin.js) adds that list as a Podfile source; see README.md for bare React
21
21
  # Native. With the plugin's iosSdkPath option, the same versions come from a local SDK checkout.
22
- s.dependency 'RediadsDisplay', '0.1.3'
22
+ s.dependency 'RediadsDisplay', '0.1.4'
23
23
  # Viewability measurement (Open Measurement), found by the SDK at run time.
24
- s.dependency 'RediadsOM', '0.1.3'
24
+ s.dependency 'RediadsOM', '0.1.4'
25
25
 
26
26
  s.pod_target_xcconfig = {
27
27
  'DEFINES_MODULE' => 'YES',
@@ -46,6 +46,7 @@ public class RediadsAdsModule: Module {
46
46
  }.runOnQueue(.main)
47
47
 
48
48
  AsyncFunction("loadInterstitial") { (adId: Int, placement: String, format: String, promise: Promise) in
49
+ self.discard(adId)
49
50
  let ad = RediadsInterstitial(placement: placement, format: Self.format(format))
50
51
  ad.onEvent = self.forward(adId)
51
52
  self.ads[adId] = ad
@@ -57,6 +58,7 @@ public class RediadsAdsModule: Module {
57
58
  AsyncFunction("loadRewarded") {
58
59
  (adId: Int, placement: String, rewardType: String, rewardAmount: Int, format: String,
59
60
  displaySeconds: Int, promise: Promise) in
61
+ self.discard(adId)
60
62
  let ad = RediadsRewarded(
61
63
  placement: placement,
62
64
  reward: RediadsReward(type: rewardType, amount: rewardAmount),
@@ -97,7 +99,7 @@ public class RediadsAdsModule: Module {
97
99
  }.runOnQueue(.main)
98
100
 
99
101
  AsyncFunction("destroy") { (adId: Int) in
100
- self.ads[adId] = nil
102
+ self.discard(adId)
101
103
  }.runOnQueue(.main)
102
104
 
103
105
  View(RediadsBannerSlot.self) {
@@ -121,6 +123,17 @@ public class RediadsAdsModule: Module {
121
123
  }
122
124
  }
123
125
 
126
+ /// Lets go of the ad under this ID, as Android's `discard` does: a load under an ID in use (JavaScript
127
+ /// reuses an ad's ID when it loads again) replaces the old ad, and none of the old ad's events, such as
128
+ /// a late `loaded` or the `dismissed` of one still on screen, reach JavaScript as the new ad's.
129
+ private func discard(_ adId: Int) {
130
+ switch self.ads.removeValue(forKey: adId) {
131
+ case let ad as RediadsInterstitial: ad.onEvent = nil
132
+ case let ad as RediadsRewarded: ad.onEvent = nil
133
+ default: break
134
+ }
135
+ }
136
+
124
137
  /// Sends an ad's events to JavaScript under its ID.
125
138
  private func forward(_ adId: Int) -> (RediadsAdEvent) -> Void {
126
139
  return { [weak self] event in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rediads/react-native-ads",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0",
4
4
  "description": "Banner, interstitial and rewarded ads from the Rediads SDK for React Native apps on iOS and Android.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -31,7 +31,13 @@
31
31
  * `use_expo_modules!`), not to app extensions, which can't use the SDK (it uses UIApplication.shared).
32
32
  * Android with androidMavenRepo: the folder goes to `allprojects.repositories` in android/build.gradle.
33
33
  */
34
- const { createRunOncePlugin, withPodfile, withProjectBuildGradle } = require('expo/config-plugins');
34
+ const {
35
+ AndroidConfig,
36
+ createRunOncePlugin,
37
+ withGradleProperties,
38
+ withPodfile,
39
+ withProjectBuildGradle,
40
+ } = require('expo/config-plugins');
35
41
  const fs = require('fs');
36
42
  const path = require('path');
37
43
  const { pathToFileURL } = require('url');
@@ -134,6 +140,114 @@ function mavenUrl(projectRoot, option) {
134
140
  return pathToFileURL(folder).href;
135
141
  }
136
142
 
143
+ const GOOGLE_MOBILE_ADS = 'react-native-google-mobile-ads';
144
+
145
+ /**
146
+ * Google's app IDs for the AdMob and GAM plugins (one call each), in apps that may also use
147
+ * react-native-google-mobile-ads. Google's SDK reads one app ID per platform, so an ID given only to
148
+ * that library's config plugin is used here too, and two different IDs are an error. `withGoogleMobileAds`
149
+ * says whether that plugin is in the app's plugin list.
150
+ *
151
+ * @param {import('expo/config').ExpoConfig} config
152
+ * @param {string} tag the calling plugin's name, for errors
153
+ * @param {{ iosAppId?: string, androidAppId?: string }} ids the calling plugin's options
154
+ */
155
+ function googleAppIds(config, tag, ids) {
156
+ const entry = (config.plugins ?? [])
157
+ .map((plugin) => (Array.isArray(plugin) ? plugin : [plugin]))
158
+ .find(([name]) => name === GOOGLE_MOBILE_ADS);
159
+ if (!entry) {
160
+ return { iosAppId: ids.iosAppId, androidAppId: ids.androidAppId, withGoogleMobileAds: false };
161
+ }
162
+ const theirs = entry[1] ?? {};
163
+ const pick = (name) => {
164
+ const ours = ids[name];
165
+ if (ours && theirs[name] && ours !== theirs[name]) {
166
+ throw new Error(
167
+ `${tag}: ${name} "${ours}" is not the "${theirs[name]}" given to ${GOOGLE_MOBILE_ADS}. Google's SDK reads one app ID per platform: give both plugins the same one, or leave it out of ${tag}'s options.`
168
+ );
169
+ }
170
+ return ours || theirs[name];
171
+ };
172
+ return { iosAppId: pick('iosAppId'), androidAppId: pick('androidAppId'), withGoogleMobileAds: true };
173
+ }
174
+
175
+ /**
176
+ * Adds (or updates) one of Google's meta-data items in the app's AndroidManifest.xml, marked
177
+ * `tools:replace="android:value"`: react-native-google-mobile-ads's library manifest declares the
178
+ * app ID item too, with the value from its own app.json key (often empty in Expo apps), and the app's
179
+ * value has to win the manifest merge.
180
+ *
181
+ * @param {import('expo/config-plugins').AndroidConfig.Manifest.AndroidManifest} manifest
182
+ * @param {string} name
183
+ * @param {string} value
184
+ */
185
+ function addGoogleMetaData(manifest, name, value) {
186
+ const { Manifest } = AndroidConfig;
187
+ Manifest.ensureToolsAvailable(manifest);
188
+ const application = Manifest.getMainApplicationOrThrow(manifest);
189
+ Manifest.addMetaDataItemToMainApplication(application, name, value);
190
+ const item = application['meta-data'].find((each) => each.$['android:name'] === name);
191
+ item.$['tools:replace'] = 'android:value';
192
+ }
193
+
194
+ /** The Gradle property the AdMob and GAM packages' android/build.gradle read. */
195
+ const GOOGLE_ADS_VERSION_PROPERTY = 'rediadsGoogleMobileAdsVersion';
196
+ const GOOGLE_ADS_VERSION_PLUGINS = ['@rediads/react-native-ads-admob', '@rediads/react-native-ads-gam'];
197
+ /** The oldest Google Mobile Ads SDK (Android) the Rediads SDK works with. */
198
+ const GOOGLE_ADS_MINIMUM = [23, 0, 0];
199
+
200
+ /**
201
+ * Sets (or, without the option, removes) the Gradle property with the Google Mobile Ads SDK version
202
+ * the AdMob and GAM packages add when nothing else in the app asks for play-services-ads. Their
203
+ * android/build.gradle adds it as a "prefer", so the app's own version (or
204
+ * react-native-google-mobile-ads's) always wins over it. "none" adds nothing. Both plugins may give it;
205
+ * two different values are an error.
206
+ *
207
+ * @param {import('expo/config').ExpoConfig} config
208
+ * @param {string} tag the calling plugin's name, for errors
209
+ * @param {string | undefined} version the calling plugin's androidGoogleMobileAdsVersion option
210
+ */
211
+ function withGoogleMobileAdsVersion(config, tag, version) {
212
+ if (version !== undefined) {
213
+ const text = String(version);
214
+ const parts = text.split('.').map(Number);
215
+ const tooOld =
216
+ parts.length === 3 &&
217
+ parts.every(Number.isInteger) &&
218
+ (parts[0] - GOOGLE_ADS_MINIMUM[0] || parts[1] - GOOGLE_ADS_MINIMUM[1] || parts[2] - GOOGLE_ADS_MINIMUM[2]) < 0;
219
+ if (text !== 'none' && (!/^\d+\.\d+\.\d+$/.test(text) || tooOld)) {
220
+ throw new Error(
221
+ `${tag}: androidGoogleMobileAdsVersion "${text}" must be a Google Mobile Ads SDK version, 23.0.0 or newer (like "25.5.0"), or "none".`
222
+ );
223
+ }
224
+ for (const plugin of config.plugins ?? []) {
225
+ if (!Array.isArray(plugin) || !GOOGLE_ADS_VERSION_PLUGINS.includes(plugin[0])) continue;
226
+ const theirs = plugin[1]?.androidGoogleMobileAdsVersion;
227
+ if (theirs !== undefined && String(theirs) !== text) {
228
+ throw new Error(
229
+ `${tag}: androidGoogleMobileAdsVersion "${text}" differs from the "${theirs}" given to ${plugin[0]}. Give both plugins the same one, or only one of them.`
230
+ );
231
+ }
232
+ }
233
+ }
234
+ return withGradleProperties(config, (config) => {
235
+ const others = config.modResults.filter(
236
+ (item) => !(item.type === 'property' && item.key === GOOGLE_ADS_VERSION_PROPERTY)
237
+ );
238
+ const given = (config.plugins ?? []).some(
239
+ (plugin) => Array.isArray(plugin) && GOOGLE_ADS_VERSION_PLUGINS.includes(plugin[0]) && plugin[1]?.androidGoogleMobileAdsVersion !== undefined
240
+ );
241
+ // Removed only when no Rediads plugin gives it: the other plugin may have set it already.
242
+ if (version === undefined) {
243
+ if (!given) config.modResults = others;
244
+ return config;
245
+ }
246
+ config.modResults = [...others, { type: 'property', key: GOOGLE_ADS_VERSION_PROPERTY, value: String(version) }];
247
+ return config;
248
+ });
249
+ }
250
+
137
251
  /**
138
252
  * @param {import('expo/config').ExpoConfig} config
139
253
  * @param {{ iosSdkPath?: string, androidMavenRepo?: string } | undefined} options
@@ -172,3 +286,6 @@ module.exports = createRunOncePlugin(withRediadsAds, pkg.name, pkg.version);
172
286
  module.exports.addPods = addPods;
173
287
  module.exports.addSources = addSources;
174
288
  module.exports.addMavenRepo = addMavenRepo;
289
+ module.exports.googleAppIds = googleAppIds;
290
+ module.exports.addGoogleMetaData = addGoogleMetaData;
291
+ module.exports.withGoogleMobileAdsVersion = withGoogleMobileAdsVersion;