this is mopub sdk react native library compatible with expo
$ yarn add expo-mopub
$ react-native link expo-mopub
pod init
``
target ‘PROJECT_NAME’ do`.pod ‘React’, :path => ‘../node_modules/react-native’, :subspecs => [
‘Core’,
‘CxxBridge’, # Include this for RN >= 0.47
‘DevSupport’, # Include this to enable In-App Devmenu if RN >= 0.43
‘RCTText’,
‘RCTNetwork’,
‘RCTWebSocket’, # Needed for debugging
‘RCTAnimation’, # Needed for FlatList and animations running on native UI thread
]
pod ‘yoga’, :path => ‘../node_modules/react-native/ReactCommon/yoga’
pod ‘DoubleConversion’, :podspec => ‘../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec’
pod ‘glog’, :podspec => ‘../node_modules/react-native/third-party-podspecs/glog.podspec’
pod ‘Folly’, :podspec => ‘../node_modules/react-native/third-party-podspecs/Folly.podspec’
pod ‘expo-mopub’, path: ‘../node_modules/expo-mopub’
end
3. Then run the following command in termainal in the same location
pod install
### Android
1. Add following permissions to your android AndroidManifest.xml.
2. Declare the following activities in your <application> AndroidManifest.xml.
3. Add following lines to build.gradle `allprojects`➜ `repositories`
```java
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
maven { url 'https://adcolony.bintray.com/AdColony' }
maven { url 'https://tapjoy.bintray.com/maven' }
maven { url 'https://jitpack.io' }
import {RNMoPubInterstitial} from 'expo-mopub';
Mehod | Description |
---|---|
initializeInterstitialAd (adUnitId: string) | Initialize Interstitial ad for the the given ad unit. |
loadAd () | Loads ad for the unit provided through initialization. |
setKeywords (keywords: string) | Set keyword for the ad. |
isReady () | Return a promise to check whether Interstitial is ready. |
show () | Shows Interstitial if loaded. |
addEventListener (eventType: string, listener: Function) | Adds listener to the events from Interstitial ad, possible event names are “onLoaded” “onFailed”, “onClicked”, “onShown” and “onDismissed”. |
removeAllListeners (eventType: string) | Remove listeners for added for events from Interstitial ad. |
import {MoPubBanner} from 'expo-mopub';
Prop | Type | Description |
---|---|---|
adUnitId | String | Banner ad unit id for which you want to show banner ad. |
autoRefresh | Bool | Toggle auto-refresh enable or disable. |
keywords | String | Pass the keywords from your app to MoPub as a comma-separated list in the ad view. Each keyword should be formatted as a key/value pair (e.g. m_age:24). Any characters can be used except & and =. |
onLoaded | Function | Calls when the banner has successfully retrieved an ad. |
onFailed | Function | Calls when the banner has failed to retrieve an ad. You can get error message from the event object. |
onClicked | Function | Calls when the user has tapped on the banner. |
onExpanded | Function | Calls when the banner has just taken over the screen. |
onCollapsed | Function | Calls when an expanded banner has collapsed back to its original size. |