@premiumads/react-native-admob-adapter 1.0.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/LICENSE +21 -0
- package/PremiumAdsReactNativeAdmobAdapter.podspec +22 -0
- package/README.md +61 -0
- package/android/build.gradle +47 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/net/premiumads/rnadapter/PremiumAdsAdapterModule.kt +21 -0
- package/android/src/main/java/net/premiumads/rnadapter/PremiumAdsAdapterPackage.kt +14 -0
- package/ios/PremiumAdsAdapterModule.h +4 -0
- package/ios/PremiumAdsAdapterModule.m +21 -0
- package/package.json +44 -0
- package/react-native.config.js +12 -0
- package/src/index.tsx +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PremiumAds
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'PremiumAdsReactNativeAdmobAdapter'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.description = package['description']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.authors = { 'alexgmax' => 'alex@premiumads.net' }
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platforms = { :ios => '13.0' }
|
|
14
|
+
s.source = { :git => 'https://github.com/premium-ads/google-mediation-adapter.git', :tag => "v#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = 'ios/**/*.{h,m,mm}'
|
|
17
|
+
s.requires_arc = true
|
|
18
|
+
|
|
19
|
+
s.dependency 'React-Core'
|
|
20
|
+
s.dependency 'PremiumAdsGoogleAdapter'
|
|
21
|
+
s.dependency 'Google-Mobile-Ads-SDK'
|
|
22
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @premiumads/react-native-admob-adapter
|
|
2
|
+
|
|
3
|
+
PremiumAds mediation adapter for [react-native-google-mobile-ads](https://github.com/invertase/react-native-google-mobile-ads).
|
|
4
|
+
|
|
5
|
+
Wires the PremiumAds AdMob custom-event adapter into your React Native app's Android and iOS builds so that Google Mobile Ads mediation can fill inventory from the PremiumAds network.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @premiumads/react-native-admob-adapter react-native-google-mobile-ads
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### iOS
|
|
14
|
+
|
|
15
|
+
Nothing extra to configure. `PremiumAdsGoogleAdapter` is published on CocoaPods trunk and is pulled in transitively by the wrapper podspec:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd ios && pod install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Android
|
|
22
|
+
|
|
23
|
+
Nothing extra to configure. The wrapper's `build.gradle` already adds the PremiumAds JFrog Maven repository (`https://repo.premiumads.net/artifactory/mobile-ads-sdk/`) and pulls in `net.premiumads.sdk:admob-adapter-v2` via autolinking.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import mobileAds from 'react-native-google-mobile-ads';
|
|
29
|
+
import {setDebug} from '@premiumads/react-native-admob-adapter';
|
|
30
|
+
|
|
31
|
+
// Enable verbose logging from the PremiumAds adapter (dev only)
|
|
32
|
+
setDebug(__DEV__);
|
|
33
|
+
|
|
34
|
+
mobileAds().initialize().then(statuses => {
|
|
35
|
+
console.log('Adapters:', statuses);
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Once initialized, use the standard `react-native-google-mobile-ads` APIs (`BannerAd`, `InterstitialAd`, `RewardedAd`, `AppOpenAd`, etc.). The PremiumAds adapter will receive ad requests via AdMob mediation when your ad units are configured to mediate through PremiumAds in the AdMob console.
|
|
40
|
+
|
|
41
|
+
See [samples/react-native/PremiumAdsRNSample](../samples/react-native/PremiumAdsRNSample) for a full working example.
|
|
42
|
+
|
|
43
|
+
## Supported ad formats
|
|
44
|
+
|
|
45
|
+
- Banner
|
|
46
|
+
- Interstitial
|
|
47
|
+
- Rewarded
|
|
48
|
+
- Rewarded Interstitial
|
|
49
|
+
- App Open
|
|
50
|
+
- Native (via `react-native-google-mobile-ads` native ad support)
|
|
51
|
+
|
|
52
|
+
## Versioning
|
|
53
|
+
|
|
54
|
+
This JS package is versioned independently from the native adapters. It pins:
|
|
55
|
+
|
|
56
|
+
- Android: `net.premiumads.sdk:admob-adapter-v2:1.0.8`
|
|
57
|
+
- iOS: `PremiumAdsGoogleAdapter` (1.0.6)
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT © PremiumAds
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
def safeExtGet(prop, fallback) {
|
|
2
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
apply plugin: 'com.android.library'
|
|
6
|
+
apply plugin: 'kotlin-android'
|
|
7
|
+
|
|
8
|
+
android {
|
|
9
|
+
namespace 'net.premiumads.rnadapter'
|
|
10
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 34)
|
|
11
|
+
|
|
12
|
+
defaultConfig {
|
|
13
|
+
minSdkVersion safeExtGet('minSdkVersion', 24)
|
|
14
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 34)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
compileOptions {
|
|
18
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
19
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
kotlinOptions {
|
|
23
|
+
jvmTarget = '17'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Inject the PremiumAds Maven repository into every project in the build so
|
|
28
|
+
// that the consuming app (and this library) can resolve the native AAR
|
|
29
|
+
// without requiring manual Gradle edits by the RN developer.
|
|
30
|
+
if (rootProject != project) {
|
|
31
|
+
rootProject.allprojects { p ->
|
|
32
|
+
p.repositories {
|
|
33
|
+
maven { url 'https://repo.premiumads.net/artifactory/mobile-ads-sdk/' }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
repositories {
|
|
39
|
+
mavenCentral()
|
|
40
|
+
google()
|
|
41
|
+
maven { url 'https://repo.premiumads.net/artifactory/mobile-ads-sdk/' }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
dependencies {
|
|
45
|
+
implementation 'com.facebook.react:react-android'
|
|
46
|
+
api 'net.premiumads.sdk:admob-adapter-v2:1.0.8'
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package net.premiumads.rnadapter
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import net.premiumads.sdk.adapter.PremiumAdsAdapter
|
|
7
|
+
|
|
8
|
+
class PremiumAdsAdapterModule(reactContext: ReactApplicationContext) :
|
|
9
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
10
|
+
|
|
11
|
+
override fun getName(): String = NAME
|
|
12
|
+
|
|
13
|
+
@ReactMethod
|
|
14
|
+
fun setDebug(enabled: Boolean) {
|
|
15
|
+
PremiumAdsAdapter.setDebug(enabled)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
companion object {
|
|
19
|
+
const val NAME = "PremiumAdsAdapter"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package net.premiumads.rnadapter
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class PremiumAdsAdapterPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
|
|
10
|
+
listOf(PremiumAdsAdapterModule(reactContext))
|
|
11
|
+
|
|
12
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
|
13
|
+
emptyList()
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#import "PremiumAdsAdapterModule.h"
|
|
2
|
+
|
|
3
|
+
#if __has_include(<PremiumAdsGoogleAdapter/PremiumAdsGoogleAdapter-Swift.h>)
|
|
4
|
+
#import <PremiumAdsGoogleAdapter/PremiumAdsGoogleAdapter-Swift.h>
|
|
5
|
+
#else
|
|
6
|
+
@import PremiumAdsGoogleAdapter;
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
@implementation PremiumAdsAdapterModule
|
|
10
|
+
|
|
11
|
+
RCT_EXPORT_MODULE(PremiumAdsAdapter)
|
|
12
|
+
|
|
13
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
14
|
+
return NO;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
RCT_EXPORT_METHOD(setDebug:(BOOL)enabled) {
|
|
18
|
+
[PremiumAdsAdapter setDebug:enabled];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@end
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@premiumads/react-native-admob-adapter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "PremiumAds AdMob mediation adapter for React Native (react-native-google-mobile-ads).",
|
|
5
|
+
"main": "src/index.tsx",
|
|
6
|
+
"types": "src/index.tsx",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"android/build.gradle",
|
|
10
|
+
"android/src",
|
|
11
|
+
"ios",
|
|
12
|
+
"PremiumAdsReactNativeAdmobAdapter.podspec",
|
|
13
|
+
"react-native.config.js",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react-native",
|
|
19
|
+
"admob",
|
|
20
|
+
"premiumads",
|
|
21
|
+
"mediation",
|
|
22
|
+
"ads",
|
|
23
|
+
"google-mobile-ads"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/premium-ads/google-mediation-adapter.git",
|
|
28
|
+
"directory": "react-native"
|
|
29
|
+
},
|
|
30
|
+
"author": "alexgmax <alex@premiumads.net>",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/premium-ads/google-mediation-adapter/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/premium-ads/google-mediation-adapter#readme",
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "*",
|
|
38
|
+
"react-native": ">=0.71.0",
|
|
39
|
+
"react-native-google-mobile-ads": ">=13.0.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dependency: {
|
|
3
|
+
platforms: {
|
|
4
|
+
android: {
|
|
5
|
+
sourceDir: './android',
|
|
6
|
+
packageImportPath: 'import net.premiumads.rnadapter.PremiumAdsAdapterPackage;',
|
|
7
|
+
packageInstance: 'new PremiumAdsAdapterPackage()',
|
|
8
|
+
},
|
|
9
|
+
ios: {},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
};
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {NativeModules} from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`The package '@premiumads/react-native-admob-adapter' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
`- You rebuilt the app after installing the package\n` +
|
|
6
|
+
`- You are not using Expo Go\n`;
|
|
7
|
+
|
|
8
|
+
const PremiumAdsAdapterNative = NativeModules.PremiumAdsAdapter
|
|
9
|
+
? NativeModules.PremiumAdsAdapter
|
|
10
|
+
: new Proxy(
|
|
11
|
+
{},
|
|
12
|
+
{
|
|
13
|
+
get() {
|
|
14
|
+
throw new Error(LINKING_ERROR);
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Enable or disable verbose logging for the PremiumAds mediation adapter.
|
|
21
|
+
* Call before `mobileAds().initialize()` for best results.
|
|
22
|
+
*/
|
|
23
|
+
export function setDebug(enabled: boolean): void {
|
|
24
|
+
PremiumAdsAdapterNative.setDebug(!!enabled);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default {setDebug};
|