├── android ├── app │ ├── .gitignore │ ├── .DS_Store │ ├── src │ │ ├── .DS_Store │ │ └── main │ │ │ ├── .DS_Store │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── java │ │ │ ├── .DS_Store │ │ │ └── suraj │ │ │ │ ├── .DS_Store │ │ │ │ └── tiwari │ │ │ │ ├── .DS_Store │ │ │ │ └── reactnativefbads │ │ │ │ ├── MediaViewManager.java │ │ │ │ ├── AdIconViewManager.java │ │ │ │ ├── NativeAdChoicesView.java │ │ │ │ ├── NativeAdChoicesViewManager.java │ │ │ │ ├── FBAdsPackage.java │ │ │ │ ├── BannerViewManager.java │ │ │ │ ├── NativeAdViewManager.java │ │ │ │ ├── InterstitialAdManager.java │ │ │ │ ├── NativeAdView.java │ │ │ │ ├── BannerView.java │ │ │ │ ├── AdSettingsManager.java │ │ │ │ └── NativeAdManager.java │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ └── proguard-rules.pro ├── settings.gradle ├── .DS_Store ├── build │ └── .DS_Store ├── gradle │ └── .DS_Store ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── ios ├── .DS_Store ├── ReactNativeAdsFacebook │ ├── EXBannerViewManager.h │ ├── EXAdSettingsManager.h │ ├── EXUnversioned.h │ ├── EXInterstitialAdManager.h │ ├── EXNativeMediaViewManager.h │ ├── EXAdIconViewManager.h │ ├── EXNativeAdEmitter.h │ ├── EXAdIconViewManager.m │ ├── EXNativeAdManager.h │ ├── EXNativeMediaViewManager.m │ ├── EXBannerView.h │ ├── AdChoiceManager.h │ ├── EXNativeAdEmitter.m │ ├── AdChoiceView.h │ ├── EXNativeAdView.h │ ├── EXBannerViewManager.m │ ├── AdChoiceManager.m │ ├── AdChoiceView.m │ ├── EXNativeAdView.m │ ├── EXBannerView.m │ ├── EXInterstitialAdManager.m │ ├── EXAdSettingsManager.m │ └── EXNativeAdManager.m └── ReactNativeAdsFacebook.xcodeproj │ └── project.pbxproj ├── images ├── nativeAd.png └── threed_mockup_fbNativeads.png ├── .gitignore ├── InterstitialAdManager.js ├── index.js ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── package.json ├── BannerViewManager.js ├── AdIconViewManager.js ├── MediaViewManager.js ├── TriggerableView.js ├── AdSettings.js ├── .npmignore ├── AdChoicesManager.js ├── CODE_OF_CONDUCT.md ├── NativeAdsManager.js ├── withNativeAd.js ├── readme.md └── LICENCE /android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /ios/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/ios/.DS_Store -------------------------------------------------------------------------------- /android/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/.DS_Store -------------------------------------------------------------------------------- /images/nativeAd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/images/nativeAd.png -------------------------------------------------------------------------------- /android/app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/.DS_Store -------------------------------------------------------------------------------- /android/build/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/build/.DS_Store -------------------------------------------------------------------------------- /android/gradle/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/gradle/.DS_Store -------------------------------------------------------------------------------- /android/app/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/.DS_Store -------------------------------------------------------------------------------- /android/app/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/.DS_Store -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ReactNativeFbAds 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/java/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/java/.DS_Store -------------------------------------------------------------------------------- /images/threed_mockup_fbNativeads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/images/threed_mockup_fbNativeads.png -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/java/suraj/.DS_Store -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXBannerViewManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface EXBannerViewManager : RCTViewManager 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/java/suraj/tiwari/.DS_Store -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXAdSettingsManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface EXAdSettingsManager : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXUnversioned.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | #define EX_UNVERSIONED(symbol) symbol 4 | 5 | @protocol EXUnversioned 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXInterstitialAdManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface EXInterstitialAdManager : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suraj-Tiwari/react-native-ads-facebook/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Example user template template 3 | ### Example user template 4 | 5 | # IntelliJ project files 6 | .idea 7 | *.iml 8 | out 9 | gen 10 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeMediaViewManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | @import FBAudienceNetwork; 4 | 5 | @interface EXNativeMediaViewManager : RCTViewManager 6 | @end 7 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXAdIconViewManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface EXAdIconViewManager : RCTViewManager 6 | @end 7 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeAdEmitter.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface EXNativeAdEmitter : RCTEventEmitter 4 | 5 | - (void)sendManagersState:(NSDictionary *)adManagersState; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXAdIconViewManager.m: -------------------------------------------------------------------------------- 1 | #import "EXAdIconViewManager.h" 2 | 3 | @implementation EXAdIconViewManager 4 | 5 | RCT_EXPORT_MODULE(AdIconViewManager) 6 | 7 | - (UIView *)view 8 | { 9 | return [[FBAdIconView alloc] init]; 10 | } 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeAdManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface EXNativeAdManager : RCTViewManager 5 | 6 | - (FBNativeAdsManager *) getFBAdsManager:(NSString *)placementId; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeMediaViewManager.m: -------------------------------------------------------------------------------- 1 | #import "EXNativeMediaViewManager.h" 2 | 3 | @implementation EXNativeMediaViewManager 4 | 5 | RCT_EXPORT_MODULE(MediaViewManager) 6 | 7 | - (UIView *)view 8 | { 9 | return [[FBMediaView alloc] init]; 10 | } 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /InterstitialAdManager.js: -------------------------------------------------------------------------------- 1 | import { NativeModules } from 'react-native'; 2 | 3 | const { CTKInterstitialAdManager } = NativeModules; 4 | 5 | export default { 6 | /** 7 | * Shows interstitial ad for a given placementId 8 | */ 9 | showAd(placementId: string): Promise { 10 | return CTKInterstitialAdManager.showAd(placementId); 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXBannerView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface EXBannerView : RCTView 5 | 6 | @property (nonatomic, copy) RCTBubblingEventBlock onAdPress; 7 | @property (nonatomic, copy) RCTBubblingEventBlock onAdError; 8 | 9 | @property (nonatomic, strong) NSNumber *size; 10 | @property (nonatomic, strong) NSString *placementId; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/AdChoiceManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AdChoiceManager.h 3 | // ReactNativeAdsFacebook 4 | // 5 | // Created by Suraj Tiwari on 14/08/18. 6 | // Copyright © 2018 Suraj Tiwari . All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface AdChoiceManager : RCTViewManager 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeAdEmitter.m: -------------------------------------------------------------------------------- 1 | #import "EXNativeAdEmitter.h" 2 | 3 | @implementation EXNativeAdEmitter 4 | 5 | RCT_EXPORT_MODULE(CTKNativeAdEmitter) 6 | 7 | - (NSArray *)supportedEvents 8 | { 9 | return @[@"CTKNativeAdsManagersChanged"]; 10 | } 11 | 12 | - (void)sendManagersState:(NSDictionary *)adManagersState { 13 | [self sendEventWithName:@"CTKNativeAdsManagersChanged" body:adManagersState]; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | // google() 4 | jcenter() 5 | maven { url 'https://maven.google.com' } 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.0.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | jcenter() 15 | maven { url 'https://maven.google.com' } 16 | } 17 | } 18 | 19 | task clean(type: Delete) { 20 | delete rootProject.buildDir 21 | } 22 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | export { default as withNativeAd } from './withNativeAd'; 2 | export { default as AdSettings } from './AdSettings'; 3 | export { default as NativeAdsManager } from './NativeAdsManager'; 4 | export { default as InterstitialAdManager } from './InterstitialAdManager'; 5 | export { default as BannerView } from './BannerViewManager'; 6 | export { default as MediaView } from './MediaViewManager'; 7 | export { default as AdIconView } from './AdIconViewManager'; 8 | export { default as TriggerableView } from './TriggerableView'; 9 | export { default as AdChoicesView } from './AdChoicesManager'; 10 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/AdChoiceView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AdChoiceView.h 3 | // ReactNativeAdsFacebook 4 | // 5 | // Created by Suraj Tiwari on 14/08/18. 6 | // Copyright © 2018 Suraj Tiwari . All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | @interface AdChoiceView : RCTView 15 | 16 | @property (nonatomic, strong) NSString *placementId; 17 | @property (nonatomic) UIRectCorner *location; 18 | @property (nonatomic) BOOL *expandable; 19 | 20 | - (instancetype)initWithBridge:(RCTBridge *)bridge; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/MediaViewManager.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import com.facebook.ads.MediaView; 4 | import com.facebook.react.uimanager.SimpleViewManager; 5 | import com.facebook.react.uimanager.ThemedReactContext; 6 | 7 | public class MediaViewManager extends SimpleViewManager { 8 | private static final String REACT_CLASS = "MediaView"; 9 | 10 | @Override 11 | public String getName() { 12 | return REACT_CLASS; 13 | } 14 | 15 | @Override 16 | protected MediaView createViewInstance(ThemedReactContext reactContext) { 17 | return new MediaView(reactContext); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/AdIconViewManager.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import com.facebook.ads.AdIconView; 4 | import com.facebook.react.uimanager.SimpleViewManager; 5 | import com.facebook.react.uimanager.ThemedReactContext; 6 | 7 | public class AdIconViewManager extends SimpleViewManager { 8 | private static final String REACT_CLASS = "AdIconView"; 9 | 10 | @Override 11 | public String getName() { 12 | return REACT_CLASS; 13 | } 14 | 15 | @Override 16 | protected AdIconView createViewInstance(ThemedReactContext reactContext) { 17 | return new AdIconView(reactContext); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeAdView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | 6 | @interface EXNativeAdView : RCTView 7 | 8 | // `onAdLoaded` event called when ad has been loaded 9 | @property (nonatomic, copy) RCTBubblingEventBlock onAdLoaded; 10 | 11 | // NativeAd this view has been loaded with 12 | @property (nonatomic, strong) FBNativeAd *nativeAd; 13 | 14 | - (instancetype)initWithBridge:(RCTBridge *)bridge; 15 | - (void)registerViewsForInteraction:(FBMediaView *)mediaView adIcon:(FBAdIconView *)adIconView clickableViews:(NSArray *)clickable; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | ndk { 13 | abiFilters "armeabi-v7a", "x86" 14 | } 15 | } 16 | } 17 | 18 | repositories { 19 | jcenter() 20 | maven { url 'https://maven.google.com' } 21 | } 22 | 23 | dependencies { 24 | compile 'com.facebook.react:react-native:+' 25 | compile 'com.android.support:appcompat-v7:26.1.0' 26 | compile 'com.facebook.android:audience-network-sdk:4.99.1' 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "GNU General Public License v3.0", 3 | "main": "index.js", 4 | "name": "react-native-ads-facebook", 5 | "author": "Suraj Tiwari ", 6 | "description": "Facebooks Audience network ads library", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/Suraj-Tiwari/react-native-ads-facebook.git" 10 | }, 11 | "keywords": [ 12 | "react-native", 13 | "facebook", 14 | "Audience Network", 15 | "Native ads" 16 | ], 17 | "version": "0.2.0", 18 | "rnpm": { 19 | "android": { 20 | "sourceDir": "android/app" 21 | } 22 | }, 23 | "dependencies": { 24 | "fbemitter": "^2.1.1" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXBannerViewManager.m: -------------------------------------------------------------------------------- 1 | #import "EXBannerViewManager.h" 2 | #import "EXBannerView.h" 3 | 4 | @implementation EXBannerViewManager 5 | 6 | RCT_EXPORT_MODULE(CTKBannerViewManager) 7 | 8 | @synthesize bridge = _bridge; 9 | 10 | - (UIView *)view 11 | { 12 | // if (![EXFacebook facebookAppIdFromNSBundle]) { 13 | // RCTLogWarn(@"No Facebook app id is specified. Facebook ads may have undefined behavior."); 14 | // } 15 | return [EXBannerView new]; 16 | } 17 | 18 | RCT_EXPORT_VIEW_PROPERTY(size, NSNumber) 19 | RCT_EXPORT_VIEW_PROPERTY(placementId, NSString) 20 | RCT_EXPORT_VIEW_PROPERTY(onAdPress, RCTBubblingEventBlock) 21 | RCT_EXPORT_VIEW_PROPERTY(onAdError, RCTBubblingEventBlock) 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | android.useDeprecatedNdk=true -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/NativeAdChoicesView.java: -------------------------------------------------------------------------------- 1 | /** 2 | * NativeAdChoicesView.java 3 | * suraj.tiwari.reactnativefbads 4 | * 5 | * Created by Suraj Tiwari on 07/08/18. 6 | * Copyright © 2018 Suraj Tiwari All rights reserved. 7 | */ 8 | package suraj.tiwari.reactnativefbads; 9 | 10 | import com.facebook.ads.NativeAd; 11 | import com.facebook.ads.AdChoicesView; 12 | import com.facebook.react.bridge.ReactContext; 13 | import com.facebook.react.uimanager.ThemedReactContext; 14 | import com.facebook.react.views.view.ReactViewGroup; 15 | 16 | public class NativeAdChoicesView extends ReactViewGroup { 17 | 18 | private ReactContext mContext; 19 | public NativeAdChoicesView(ThemedReactContext context) { 20 | super(context); 21 | mContext = context; 22 | } 23 | 24 | public void setNativeAd(NativeAd nativeAd) { 25 | AdChoicesView adChoicesView = new AdChoicesView(mContext, nativeAd, true); 26 | adChoicesView.measure(40, 40); 27 | adChoicesView.layout(0, 0, 40, 40); 28 | adChoicesView.bringToFront(); 29 | addView(adChoicesView); 30 | } 31 | } -------------------------------------------------------------------------------- /BannerViewManager.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { requireNativeComponent } from 'react-native'; 3 | 4 | type AdType = 'large' | 'rectangle' | 'standard'; 5 | 6 | const CTKBannerView = requireNativeComponent('CTKBannerView', null, { 7 | onAdPress: true, 8 | onAdError: true, 9 | }); 10 | 11 | const sizeForType = { 12 | large: 90, 13 | rectangle: 250, 14 | standard: 50, 15 | }; 16 | 17 | /** 18 | * Gets size for a type (any value of `AdType` is allowed) 19 | */ 20 | const getSizeForType = (type: AdType) => sizeForType[type] || sizeForType.standard; 21 | 22 | type BannerViewProps = { 23 | type: AdType, 24 | placementId: string, 25 | onPress: Function, 26 | onError: Function, 27 | style: any, 28 | }; 29 | 30 | const BannerView = (props: BannerViewProps) => { 31 | const { type, onPress, onError, style, ...restProps } = props; 32 | const size = getSizeForType(type); 33 | 34 | return ( 35 | 42 | ); 43 | }; 44 | 45 | export default BannerView; 46 | -------------------------------------------------------------------------------- /AdIconViewManager.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {requireNativeComponent} from 'react-native'; 3 | 4 | import {AdIconViewContext} from './withNativeAd'; 5 | import type {AdIconViewContextValueType} from './withNativeAd'; 6 | 7 | export const NativeAdIconView = requireNativeComponent('AdIconView', null, {}); 8 | 9 | class AdIconViewChild extends React.Component { 10 | _iconView: ?React.Node; 11 | 12 | _handleAdIconViewRef = (ref: ?React.Node) => { 13 | if (this._iconView) { 14 | this.props.unregister(this._iconView); 15 | this._iconView = null; 16 | } 17 | 18 | if (ref) { 19 | this.props.register(ref); 20 | this._iconView = ref; 21 | } 22 | }; 23 | 24 | render() { 25 | return ; 26 | } 27 | } 28 | 29 | export default class AdIconView extends React.Component { 30 | render() { 31 | return ( 32 | 33 | {(contextValue: AdIconViewContextValueType) => ( 34 | 35 | )} 36 | 37 | ); 38 | } 39 | } -------------------------------------------------------------------------------- /MediaViewManager.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {requireNativeComponent} from 'react-native'; 3 | 4 | import {MediaViewContext} from './withNativeAd'; 5 | import type {MediaViewContextValueType} from './withNativeAd'; 6 | 7 | export const NativeMediaView = requireNativeComponent('MediaView', null, {}); 8 | 9 | class MediaViewChild extends React.Component { 10 | _mediaView: ?React.Node; 11 | 12 | _handleMediaViewMount = (ref: ?React.Node) => { 13 | if (this._mediaView) { 14 | this.props.unregister(this._mediaView); 15 | this._mediaView = null; 16 | } 17 | 18 | if (ref) { 19 | this.props.register(ref); 20 | this._mediaView = ref; 21 | } 22 | }; 23 | 24 | render() { 25 | return ; 26 | } 27 | } 28 | 29 | export default class MediaView extends React.Component { 30 | render() { 31 | return ( 32 | 33 | {(contextValue: MediaViewContextValueType) => ( 34 | 35 | )} 36 | 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /TriggerableView.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {findNodeHandle, requireNativeComponent, View, ViewPropTypes,Text} from 'react-native'; 3 | 4 | import { TriggerableContext } from './withNativeAd'; 5 | import type { TriggerableContextValueType } from './withNativeAd'; 6 | 7 | type PropsType = ViewPropTypes & TriggerableContextValueType; 8 | 9 | const NativeTriggerableView = requireNativeComponent('AdTriggerableView', null, {}); 10 | 11 | class TriggerableViewChild extends React.Component { 12 | _wrapperRef: ?View; 13 | 14 | _handleWrapperRef = (ref: ?View) => { 15 | if (this._wrapperRef) { 16 | this.props.unregister(this._wrapperRef); 17 | this._wrapperRef = null; 18 | } 19 | 20 | if (ref) { 21 | this.props.register(ref); 22 | this._wrapperRef = ref; 23 | } 24 | }; 25 | 26 | render() { 27 | return ; 28 | } 29 | } 30 | 31 | export default class TriggerableView extends React.Component { 32 | render() { 33 | return ( 34 | 35 | {(contextValue: TriggerableContextValueType) => ( 36 | 37 | )} 38 | 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/AdChoiceManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // AdChoiceManager.m 3 | // ReactNativeAdsFacebook 4 | // 5 | // Created by Suraj Tiwari on 14/08/18. 6 | // Copyright © 2018 Suraj Tiwari . All rights reserved. 7 | // 8 | #import "AdChoiceManager.h" 9 | #import "EXNativeAdManager.h" 10 | #import "AdChoiceView.h" 11 | #import 12 | 13 | @implementation RCTConvert (AdChoiceView) 14 | 15 | RCT_ENUM_CONVERTER(UIRectCorner, (@{ 16 | @"topRight": @(UIRectCornerTopRight), 17 | @"topLeft": @(UIRectCornerTopLeft), 18 | @"bottomLeft": @(UIRectCornerBottomLeft), 19 | @"bottomRight": @(UIRectCornerBottomRight) 20 | }), UIRectCornerTopRight, intValue ) 21 | @end 22 | 23 | @implementation AdChoiceManager 24 | 25 | RCT_EXPORT_MODULE(AdChoicesView) 26 | 27 | @synthesize bridge = _bridge; 28 | 29 | - (instancetype)init 30 | { 31 | self = [super init]; 32 | return self; 33 | } 34 | 35 | - (UIView *)view 36 | { 37 | return [[AdChoiceView new] initWithBridge:_bridge]; 38 | } 39 | 40 | RCT_EXPORT_VIEW_PROPERTY(placementId,NSString); 41 | RCT_EXPORT_VIEW_PROPERTY(location,UIRectCorner); 42 | RCT_EXPORT_VIEW_PROPERTY(expandable,BOOL); 43 | 44 | @end 45 | 46 | -------------------------------------------------------------------------------- /AdSettings.js: -------------------------------------------------------------------------------- 1 | import { NativeModules } from 'react-native'; 2 | 3 | const { CTKAdSettingsManager } = NativeModules; 4 | 5 | type SDKLogLevel = 'none' | 'debug' | 'verbose' | 'warning' | 'error' | 'notification'; 6 | 7 | export default { 8 | /** 9 | * Contains hash of the device id 10 | */ 11 | get currentDeviceHash(): string { 12 | return CTKAdSettingsManager.currentDeviceHash; 13 | }, 14 | 15 | /** 16 | * Registers given device with `deviceHash` to receive test Facebook ads. 17 | */ 18 | addTestDevice(deviceHash: string) { 19 | CTKAdSettingsManager.addTestDevice(deviceHash); 20 | }, 21 | /** 22 | * Clears previously set test devices 23 | */ 24 | clearTestDevices() { 25 | CTKAdSettingsManager.clearTestDevices(); 26 | }, 27 | /** 28 | * Sets current SDK log level 29 | */ 30 | setLogLevel(logLevel: SDKLogLevel) { 31 | CTKAdSettingsManager.setLogLevel(logLevel); 32 | }, 33 | /** 34 | * Specifies whether ads are treated as child-directed 35 | */ 36 | setIsChildDirected(isDirected: boolean) { 37 | CTKAdSettingsManager.setIsChildDirected(isDirected); 38 | }, 39 | /** 40 | * Sets mediation service name 41 | */ 42 | setMediationService(mediationService: string) { 43 | CTKAdSettingsManager.setMediationService(mediationService); 44 | }, 45 | /** 46 | * Sets URL prefix 47 | */ 48 | setUrlPrefix(urlPrefix: string) { 49 | CTKAdSettingsManager.setUrlPrefix(urlPrefix); 50 | }, 51 | }; 52 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/NativeAdChoicesViewManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * NativeAdChoiceViewManager.java 3 | * suraj.tiwari.reactnativefbads 4 | * 5 | * Created by Suraj Tiwari on 07/08/18. 6 | * Copyright © 2018 Suraj Tiwari All rights reserved. 7 | */ 8 | 9 | package suraj.tiwari.reactnativefbads; 10 | 11 | import com.facebook.ads.NativeAdsManager; 12 | import com.facebook.react.bridge.ReactApplicationContext; 13 | import com.facebook.react.uimanager.SimpleViewManager; 14 | import com.facebook.react.uimanager.ThemedReactContext; 15 | import com.facebook.react.uimanager.annotations.ReactProp; 16 | 17 | public class NativeAdChoicesViewManager extends SimpleViewManager { 18 | ReactApplicationContext mReactContext; 19 | 20 | private static final String REACT_CLASS = "AdChoicesView"; 21 | 22 | @Override 23 | public String getName() { 24 | return REACT_CLASS; 25 | } 26 | 27 | public NativeAdChoicesViewManager(ReactApplicationContext context) { 28 | super(); 29 | mReactContext = context; 30 | } 31 | 32 | @ReactProp(name = "placementId") 33 | public void adsManager(NativeAdChoicesView view, String adsManagerId) { 34 | NativeAdManager adManager = mReactContext.getNativeModule(NativeAdManager.class); 35 | NativeAdsManager adsManager = adManager.getFBAdsManager(adsManagerId); 36 | 37 | view.setNativeAd(adsManager.nextNativeAd()); 38 | } 39 | 40 | @Override 41 | protected NativeAdChoicesView createViewInstance(ThemedReactContext reactContext) { 42 | return new NativeAdChoicesView(reactContext); 43 | } 44 | } -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Example user template template 3 | ### Example user template 4 | 5 | # IntelliJ project files 6 | .idea 7 | *.iml 8 | out 9 | gen### Node template 10 | # Logs 11 | logs 12 | *.log 13 | npm-debug.log* 14 | yarn-debug.log* 15 | yarn-error.log* 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules/ 46 | jspm_packages/ 47 | 48 | # TypeScript v1 declaration files 49 | typings/ 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional REPL history 58 | .node_repl_history 59 | 60 | # Output of 'npm pack' 61 | *.tgz 62 | 63 | # Yarn Integrity file 64 | .yarn-integrity 65 | 66 | # dotenv environment variables file 67 | .env 68 | 69 | # parcel-bundler cache (https://parceljs.org/) 70 | .cache 71 | 72 | # next.js build output 73 | .next 74 | 75 | # nuxt.js build output 76 | .nuxt 77 | 78 | # vuepress build output 79 | .vuepress/dist 80 | 81 | # Serverless directories 82 | .serverless 83 | 84 | images 85 | .github 86 | CODE_OF_CONDUCT.md 87 | 88 | 89 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/FBAdsPackage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FBAdsPackage.java 3 | * suraj.tiwari.reactnativefbads 4 | * 5 | * Created by Suraj Tiwari on 07/08/18. 6 | * Copyright © 2018 Suraj Tiwari All rights reserved. 7 | */ 8 | package suraj.tiwari.reactnativefbads; 9 | 10 | import com.facebook.react.ReactPackage; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | import com.facebook.react.bridge.NativeModule; 13 | import com.facebook.react.bridge.ReactApplicationContext; 14 | import com.facebook.react.uimanager.ViewManager; 15 | 16 | import java.util.Arrays; 17 | import java.util.Collections; 18 | import java.util.List; 19 | 20 | /** 21 | * Main package exporting native modules and views 22 | */ 23 | public class FBAdsPackage implements ReactPackage { 24 | @Override 25 | public List createNativeModules(ReactApplicationContext reactContext) { 26 | return Arrays.asList( 27 | new NativeAdManager(reactContext), 28 | new AdSettingsManager(reactContext), 29 | new InterstitialAdManager(reactContext), 30 | new NativeAdChoicesViewManager(reactContext) 31 | ); 32 | } 33 | 34 | // Deprecated RN 0.47 35 | public List> createJSModules() { 36 | return Collections.emptyList(); 37 | } 38 | 39 | @Override 40 | public List createViewManagers(ReactApplicationContext reactContext) { 41 | return Arrays.asList( 42 | new NativeAdViewManager(), 43 | new BannerViewManager(), 44 | new AdIconViewManager(), 45 | new MediaViewManager(), 46 | new NativeAdChoicesViewManager(reactContext) 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/AdChoiceView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AdChoiceView.m 3 | // ReactNativeAdsFacebook 4 | // 5 | // Created by Suraj Tiwari on 14/08/18. 6 | // Copyright © 2018 Suraj Tiwari . All rights reserved. 7 | // 8 | 9 | #import "AdChoiceView.h" 10 | #import 11 | #import "EXNativeAdManager.h" 12 | 13 | @interface AdChoiceView () 14 | @property (nonatomic, strong) RCTBridge *bridge; 15 | @end 16 | 17 | @implementation AdChoiceView 18 | 19 | - (instancetype)initWithBridge:(RCTBridge *)bridge 20 | { 21 | if (self = [super init]) { 22 | _bridge = bridge; 23 | } 24 | return self; 25 | } 26 | 27 | - (void)setPlacementId:(NSString *)placementId 28 | { 29 | _placementId = placementId; 30 | [self createViewIfCan:_placementId:_location: _expandable]; 31 | } 32 | 33 | - (void)setLocation:(UIRectCorner *)location 34 | { 35 | _location = location; 36 | [self createViewIfCan:_placementId:_location: _expandable]; 37 | } 38 | 39 | - (void)setExpandable:(BOOL *)expandable 40 | { 41 | _expandable = expandable; 42 | [self createViewIfCan:_placementId :_location :_expandable]; 43 | } 44 | 45 | - (void)createViewIfCan:(NSString *)placementId :(UIRectCorner *) location :(BOOL) expandable 46 | { 47 | if (!location || !placementId) { 48 | return; 49 | } 50 | EXNativeAdManager *nativeAdManager = [_bridge moduleForClass:[EXNativeAdManager class]]; 51 | FBNativeAdsManager *_adsManager = [nativeAdManager getFBAdsManager:placementId]; 52 | FBNativeAd *nativeAd = [_adsManager nextNativeAd]; 53 | FBAdChoicesView *adChoicesView = [[FBAdChoicesView alloc] initWithNativeAd:nativeAd expandable:expandable]; 54 | [adChoicesView updateFrameFromSuperview:location]; 55 | [self addSubview:adChoicesView]; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/BannerViewManager.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | 4 | import android.support.annotation.Nullable; 5 | 6 | import com.facebook.ads.AdSize; 7 | import com.facebook.react.bridge.ReactContext; 8 | import com.facebook.react.bridge.ReadableMap; 9 | import com.facebook.react.common.MapBuilder; 10 | import com.facebook.react.uimanager.SimpleViewManager; 11 | import com.facebook.react.uimanager.ThemedReactContext; 12 | import com.facebook.react.uimanager.annotations.ReactProp; 13 | 14 | import java.util.Map; 15 | 16 | public class BannerViewManager extends SimpleViewManager { 17 | @ReactProp(name = "placementId") 18 | public void setPlacementId(BannerView view, String placementId) { 19 | view.setPlacementId(placementId); 20 | } 21 | 22 | @ReactProp(name = "size") 23 | public void setSize(BannerView view, int size) { 24 | AdSize adSize = null; 25 | switch (size) { 26 | case 90: 27 | adSize = AdSize.BANNER_HEIGHT_90; 28 | break; 29 | case 250: 30 | adSize = AdSize.RECTANGLE_HEIGHT_250; 31 | case 50: 32 | default: 33 | adSize = AdSize.BANNER_HEIGHT_50; 34 | } 35 | view.setSize(adSize); 36 | } 37 | 38 | @Override 39 | protected BannerView createViewInstance(ThemedReactContext reactContext) { 40 | return new BannerView(reactContext); 41 | } 42 | 43 | @Override 44 | public @Nullable Map getExportedCustomDirectEventTypeConstants() { 45 | return MapBuilder.of( 46 | "onAdPress", 47 | MapBuilder.of("registrationName", "onAdPress"), 48 | "onAdError", 49 | MapBuilder.of("registrationName", "onAdError"), 50 | "onLoggingImpression", 51 | MapBuilder.of("registrationName", "onLoggingImpression") 52 | ); 53 | } 54 | 55 | @Override 56 | public String getName() { 57 | return "CTKBannerView"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /AdChoicesManager.js: -------------------------------------------------------------------------------- 1 | import React, {PropTypes} from 'react'; 2 | import {requireNativeComponent, StyleSheet, Platform} from 'react-native'; 3 | 4 | const NativeAdChoicesView = requireNativeComponent('AdChoicesView', null); 5 | let positionStyle = null; 6 | 7 | type adChoiceLocation = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'; 8 | 9 | export default class AdChoicesView extends React.Component { 10 | 11 | location: adChoiceLocation 12 | 13 | componentWillMount() { 14 | positionStyle = styles.topRight; 15 | 16 | location = this.props.position; 17 | 18 | if (location === 'topLeft') { 19 | positionStyle = styles.topLeft 20 | } else if (location === 'topRight') { 21 | positionStyle = styles.topRight 22 | } else if (location === 'bottomLeft') { 23 | positionStyle = styles.bottomLeft 24 | } else if (location === 'bottomRight') { 25 | positionStyle = styles.bottomRight 26 | } 27 | } 28 | 29 | render() { 30 | return ( 31 | 34 | ); 35 | } 36 | } 37 | 38 | let styles = StyleSheet.create({ 39 | adChoice: { 40 | backgroundColor: 'transparent', 41 | ...Platform.select({ 42 | ios: { 43 | width: 0, height: 0, 44 | }, 45 | android: { 46 | width: 22, height: 22, 47 | }, 48 | }), 49 | position: 'absolute', 50 | }, 51 | topLeft: { 52 | left: 0, 53 | top: 0, 54 | }, 55 | topRight: { 56 | top: 0, 57 | right: 0 58 | }, 59 | bottomLeft: { 60 | left: 0, 61 | bottom: 0, 62 | }, 63 | bottomRight: { 64 | bottom: 0, 65 | right: 0 66 | } 67 | 68 | }) 69 | 70 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeAdView.m: -------------------------------------------------------------------------------- 1 | #import "EXNativeAdView.h" 2 | #import 3 | #import 4 | 5 | @interface EXNativeAdView () 6 | 7 | @property (nonatomic, strong) RCTBridge *bridge; 8 | 9 | @end 10 | 11 | @implementation EXNativeAdView 12 | 13 | - (instancetype)initWithBridge:(RCTBridge *)bridge 14 | { 15 | if (self = [super init]) { 16 | _bridge = bridge; 17 | } 18 | return self; 19 | } 20 | 21 | - (void)setOnAdLoaded:(RCTBubblingEventBlock)onAdLoaded 22 | { 23 | _onAdLoaded = onAdLoaded; 24 | 25 | if (_nativeAd != nil) { 26 | [self callOnAdLoadedWithAd:_nativeAd]; 27 | } 28 | } 29 | 30 | - (void)setNativeAd:(FBNativeAd *)nativeAd 31 | { 32 | _nativeAd = nativeAd; 33 | [self callOnAdLoadedWithAd:_nativeAd]; 34 | } 35 | 36 | - (void)callOnAdLoadedWithAd:(FBNativeAd *)nativeAd 37 | { 38 | if (_onAdLoaded != nil) { 39 | _onAdLoaded(@{ 40 | @"advertiserName": nativeAd.advertiserName, 41 | @"sponsoredTranslation": nativeAd.sponsoredTranslation, 42 | @"bodyText": nativeAd.bodyText, 43 | @"socialContext": nativeAd.socialContext, 44 | @"callToActionText": nativeAd.callToAction, 45 | @"translation": nativeAd.adTranslation, 46 | @"linkDescription": nativeAd.linkDescription, 47 | @"promotedTranslation": nativeAd.promotedTranslation, 48 | @"headline": nativeAd.headline, 49 | }); 50 | } 51 | } 52 | 53 | - (void)registerViewsForInteraction:(FBMediaView *)mediaView adIcon:(FBAdIconView *)adIconView clickableViews:(NSArray *)clickable 54 | { 55 | [_nativeAd registerViewForInteraction:self 56 | mediaView:mediaView 57 | iconView:adIconView 58 | viewController:RCTKeyWindow().rootViewController 59 | clickableViews:clickable]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXBannerView.m: -------------------------------------------------------------------------------- 1 | #import "EXBannerView.h" 2 | 3 | #import 4 | #import 5 | 6 | @interface EXBannerView () 7 | 8 | @property (nonatomic, strong) FBAdView *adView; 9 | 10 | @end 11 | 12 | @implementation EXBannerView 13 | 14 | - (void)setSize:(NSNumber *)size 15 | { 16 | _size = size; 17 | [self createViewIfCan]; 18 | } 19 | 20 | - (void)setPlacementId:(NSString *)placementId 21 | { 22 | _placementId = placementId; 23 | [self createViewIfCan]; 24 | } 25 | 26 | // Initialise BannerAdView as soon as all the props are set 27 | - (void)createViewIfCan 28 | { 29 | if (!_placementId || !_size) { 30 | return; 31 | } 32 | 33 | if (_adView) { 34 | [_adView removeFromSuperview]; 35 | } 36 | 37 | FBAdSize fbAdSize = [self fbAdSizeForHeight:_size]; 38 | 39 | FBAdView *adView = [[FBAdView alloc] initWithPlacementID:_placementId 40 | adSize:fbAdSize 41 | rootViewController:RCTPresentedViewController()]; 42 | 43 | adView.frame = CGRectMake(0, 20, adView.bounds.size.width, adView.bounds.size.height); 44 | adView.delegate = self; 45 | 46 | [adView loadAd]; 47 | 48 | [self addSubview:adView]; 49 | 50 | _adView = adView; 51 | } 52 | 53 | - (FBAdSize)fbAdSizeForHeight:(NSNumber *)height 54 | { 55 | switch ([height intValue]) { 56 | case 90: 57 | return kFBAdSizeHeight90Banner; 58 | case 250: 59 | return kFBAdSizeHeight250Rectangle; 60 | case 50: 61 | default: 62 | return kFBAdSizeHeight50Banner; 63 | } 64 | } 65 | 66 | # pragma mark - FBAdViewDelegate 67 | 68 | - (void)adViewDidClick:(FBAdView *)adView 69 | { 70 | if (_onAdPress) { 71 | _onAdPress(nil); 72 | } 73 | } 74 | 75 | - (void)adView:(FBAdView *)adView didFailWithError:(NSError *)error 76 | { 77 | if (_onAdError) { 78 | _onAdError(RCTJSErrorFromNSError(error)); 79 | } else { 80 | RCTMakeAndLogError(error.localizedDescription, nil, error.userInfo); 81 | } 82 | } 83 | 84 | - (void)adViewDidFinishHandlingClick:(FBAdView *)adView {} 85 | - (void)adViewWillLogImpression:(FBAdView *)adView {} 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/NativeAdViewManager.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.util.Log; 6 | import android.view.View; 7 | 8 | import com.facebook.ads.NativeAdsManager; 9 | import com.facebook.react.bridge.ReactContext; 10 | import com.facebook.react.common.MapBuilder; 11 | import com.facebook.react.uimanager.ThemedReactContext; 12 | import com.facebook.react.uimanager.ViewGroupManager; 13 | import com.facebook.react.uimanager.annotations.ReactProp; 14 | 15 | import java.util.Map; 16 | 17 | public class NativeAdViewManager extends ViewGroupManager { 18 | private static String NAME = "CTKNativeAd"; 19 | 20 | @Override 21 | public String getName() { 22 | return NAME; 23 | } 24 | 25 | @Override 26 | protected NativeAdView createViewInstance(ThemedReactContext reactContext) { 27 | return new NativeAdView(reactContext); 28 | } 29 | 30 | @ReactProp(name = "adsManager") 31 | public void setAdsManager(NativeAdView view, String adsManagerId) { 32 | Context viewContext = view.getContext(); 33 | if (viewContext instanceof ReactContext) { 34 | ReactContext reactContext = (ReactContext) viewContext; 35 | NativeAdManager adManager = reactContext.getNativeModule(NativeAdManager.class); 36 | NativeAdsManager adsManager = adManager.getFBAdsManager(adsManagerId); 37 | 38 | view.setNativeAd(adsManager.nextNativeAd()); 39 | } else { 40 | Log.e("E_NOT_RCT_CONTEXT", "View's context is not a ReactContext, so it's not possible to get NativeAdManager."); 41 | } 42 | } 43 | 44 | @Override 45 | @Nullable 46 | public Map getExportedCustomDirectEventTypeConstants() { 47 | return MapBuilder.of( 48 | "onAdLoaded", 49 | MapBuilder.of("registrationName", "onAdLoaded"), 50 | "onAdFailed", 51 | MapBuilder.of("registrationName", "onAdFailed") 52 | ); 53 | } 54 | 55 | @Override 56 | public void addView(NativeAdView parent, View child, int index) { 57 | parent.addView(child, index); 58 | } 59 | 60 | @Override 61 | public int getChildCount(NativeAdView parent) { 62 | return parent.getChildCount(); 63 | } 64 | 65 | @Override 66 | public View getChildAt(NativeAdView parent, int index) { 67 | return parent.getChildAt(index); 68 | } 69 | 70 | @Override 71 | public void removeViewAt(NativeAdView parent, int index) { 72 | parent.removeViewAt(index); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/InterstitialAdManager.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import com.facebook.ads.Ad; 4 | import com.facebook.ads.AdError; 5 | import com.facebook.ads.InterstitialAd; 6 | import com.facebook.ads.InterstitialAdListener; 7 | import com.facebook.react.bridge.LifecycleEventListener; 8 | import com.facebook.react.bridge.Promise; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 11 | import com.facebook.react.bridge.ReactMethod; 12 | 13 | public class InterstitialAdManager extends ReactContextBaseJavaModule implements InterstitialAdListener, LifecycleEventListener { 14 | 15 | private Promise mPromise; 16 | private boolean mDidClick = false; 17 | private InterstitialAd mInterstitial; 18 | 19 | public InterstitialAdManager(ReactApplicationContext reactContext) { 20 | super(reactContext); 21 | reactContext.addLifecycleEventListener(this); 22 | } 23 | 24 | @ReactMethod 25 | public void showAd(String placementId, Promise p) { 26 | if (mPromise != null) { 27 | p.reject("E_FAILED_TO_SHOW", "Only one `showAd` can be called at once"); 28 | return; 29 | } 30 | ReactApplicationContext reactContext = this.getReactApplicationContext(); 31 | 32 | mPromise = p; 33 | mInterstitial = new InterstitialAd(reactContext, placementId); 34 | mInterstitial.setAdListener(this); 35 | mInterstitial.loadAd(); 36 | } 37 | 38 | @Override 39 | public String getName() { 40 | return "CTKInterstitialAdManager"; 41 | } 42 | 43 | @Override 44 | public void onError(Ad ad, AdError adError) { 45 | mPromise.reject("E_FAILED_TO_LOAD", adError.getErrorMessage()); 46 | cleanUp(); 47 | } 48 | 49 | @Override 50 | public void onAdLoaded(Ad ad) { 51 | if (ad == mInterstitial) { 52 | mInterstitial.show(); 53 | } 54 | } 55 | 56 | @Override 57 | public void onAdClicked(Ad ad) { 58 | mDidClick = true; 59 | } 60 | 61 | @Override 62 | public void onInterstitialDismissed(Ad ad) { 63 | mPromise.resolve(mDidClick); 64 | cleanUp(); 65 | } 66 | 67 | @Override 68 | public void onInterstitialDisplayed(Ad ad) { 69 | 70 | } 71 | 72 | @Override 73 | public void onLoggingImpression(Ad ad) { 74 | } 75 | 76 | private void cleanUp() { 77 | mPromise = null; 78 | mDidClick = false; 79 | 80 | if (mInterstitial != null) { 81 | mInterstitial.destroy(); 82 | mInterstitial = null; 83 | } 84 | } 85 | 86 | @Override 87 | public void onHostResume() { 88 | 89 | } 90 | 91 | @Override 92 | public void onHostPause() { 93 | 94 | } 95 | 96 | @Override 97 | public void onHostDestroy() { 98 | cleanUp(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/NativeAdView.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import android.graphics.drawable.Icon; 4 | import android.view.MotionEvent; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import com.facebook.ads.AdChoicesView; 9 | import com.facebook.ads.AdIconView; 10 | import com.facebook.ads.MediaView; 11 | import com.facebook.ads.NativeAd; 12 | import com.facebook.react.bridge.Arguments; 13 | import com.facebook.react.bridge.WritableMap; 14 | import com.facebook.react.uimanager.ThemedReactContext; 15 | import com.facebook.react.uimanager.events.RCTEventEmitter; 16 | import com.facebook.react.views.view.ReactViewGroup; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class NativeAdView extends ReactViewGroup { 22 | /** 23 | * @{NativeAd} received from the ads manager 24 | **/ 25 | private NativeAd mNativeAd; 26 | 27 | /** 28 | * @{RCTEventEmitter} instance used for sending events back to JS 29 | **/ 30 | private RCTEventEmitter mEventEmitter; 31 | 32 | /** 33 | * Creates new NativeAdView instance and retrieves event emitter 34 | * 35 | * @param context 36 | */ 37 | public NativeAdView(ThemedReactContext context) { 38 | super(context); 39 | 40 | mEventEmitter = context.getJSModule(RCTEventEmitter.class); 41 | } 42 | 43 | /** 44 | * Called by the view manager when adsManager prop is set. Sends serialised 45 | * version of a native ad back to Javascript. 46 | * 47 | * @param nativeAd 48 | */ 49 | public void setNativeAd(NativeAd nativeAd) { 50 | if (mNativeAd != null) { 51 | mNativeAd.unregisterView(); 52 | } 53 | 54 | mNativeAd = nativeAd; 55 | 56 | if (nativeAd == null) { 57 | mEventEmitter.receiveEvent(getId(), "onAdLoaded", null); 58 | return; 59 | } 60 | 61 | WritableMap event = Arguments.createMap(); 62 | event.putString("headline", nativeAd.getAdHeadline()); 63 | event.putString("socialContext", nativeAd.getAdSocialContext()); 64 | event.putString("bodyText", nativeAd.getAdBodyText()); 65 | event.putString("callToActionText", nativeAd.getAdCallToAction()); 66 | event.putString("sponsoredTranslation", nativeAd.getSponsoredTranslation()); 67 | event.putString("advertiserName", nativeAd.getAdvertiserName()); 68 | event.putString("promotedTranslation", nativeAd.getPromotedTranslation()); 69 | event.putString("translation", nativeAd.getAdTranslation()); 70 | event.putString("linkDescription", nativeAd.getAdLinkDescription()); 71 | 72 | mEventEmitter.receiveEvent(getId(), "onAdLoaded", event); 73 | } 74 | 75 | public void registerViewsForInteraction(MediaView mediaView, AdIconView adIconView, List clickableViews) { 76 | mNativeAd.registerViewForInteraction(this, mediaView, adIconView, clickableViews); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at surajtiwari020@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/BannerView.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import android.content.res.Resources; 4 | import android.util.DisplayMetrics; 5 | import android.util.TypedValue; 6 | 7 | import com.facebook.ads.Ad; 8 | import com.facebook.ads.AdError; 9 | import com.facebook.ads.AdListener; 10 | import com.facebook.ads.AdSize; 11 | import com.facebook.ads.AdView; 12 | import com.facebook.react.bridge.Arguments; 13 | import com.facebook.react.bridge.LifecycleEventListener; 14 | import com.facebook.react.bridge.ReactContext; 15 | import com.facebook.react.bridge.WritableMap; 16 | import com.facebook.react.uimanager.ThemedReactContext; 17 | import com.facebook.react.uimanager.events.RCTEventEmitter; 18 | import com.facebook.react.views.view.ReactViewGroup; 19 | 20 | 21 | public class BannerView extends ReactViewGroup implements AdListener, LifecycleEventListener { 22 | 23 | private ReactContext mContext; 24 | private AdView myAdView; 25 | private String mPlacementId; 26 | private AdSize mSize; 27 | private RCTEventEmitter mEventEmitter; 28 | 29 | public BannerView(ThemedReactContext context) { 30 | super(context); 31 | mContext = context; 32 | mContext.addLifecycleEventListener(this); 33 | mEventEmitter = mContext.getJSModule(RCTEventEmitter.class); 34 | } 35 | 36 | public void setPlacementId(String placementId) { 37 | mPlacementId = placementId; 38 | createAdViewIfCan(); 39 | } 40 | 41 | public void setSize(AdSize size) { 42 | mSize = size; 43 | createAdViewIfCan(); 44 | } 45 | 46 | @Override 47 | public void onError(Ad ad, AdError adError) { 48 | WritableMap event = Arguments.createMap(); 49 | 50 | event.putInt("errorCode", adError.getErrorCode()); 51 | event.putString("errorMessage", adError.getErrorMessage()); 52 | mEventEmitter.receiveEvent(getId(), "onAdError", event); 53 | 54 | myAdView = null; 55 | } 56 | 57 | @Override 58 | public void onAdLoaded(Ad ad) { 59 | this.removeAllViews(); 60 | 61 | Resources r = mContext.getResources(); 62 | DisplayMetrics dm = r.getDisplayMetrics(); 63 | int pxW = mSize.getWidth() > 0 ? 64 | dp2px(mSize.getWidth(), dm) 65 | : r.getDisplayMetrics().widthPixels; 66 | int pxH = dp2px(mSize.getHeight(), dm); 67 | 68 | myAdView.measure(pxW, pxH); 69 | myAdView.layout(0, 0, pxW, pxH); 70 | 71 | addView(myAdView); 72 | } 73 | 74 | @Override 75 | public void onAdClicked(Ad ad) { 76 | mEventEmitter.receiveEvent(getId(), "onAdPress", null); 77 | } 78 | 79 | @Override 80 | public void onLoggingImpression(Ad ad) { 81 | mEventEmitter.receiveEvent(getId(), "onLoggingImpression", null); 82 | } 83 | 84 | private void createAdViewIfCan() { 85 | if (myAdView == null && mPlacementId != null && mSize != null) { 86 | myAdView = new AdView(this.getContext(), mPlacementId, mSize); 87 | myAdView.setAdListener(this); 88 | 89 | myAdView.loadAd(); 90 | } 91 | } 92 | 93 | private int dp2px(int dp, DisplayMetrics dm) { 94 | return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, dm)); 95 | } 96 | 97 | @Override 98 | public void onHostResume() { 99 | 100 | } 101 | 102 | @Override 103 | public void onHostPause() { 104 | 105 | } 106 | 107 | @Override 108 | public void onHostDestroy() { 109 | if (myAdView != null) { 110 | myAdView.destroy(); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/AdSettingsManager.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.util.Log; 6 | 7 | import com.facebook.ads.AdSettings; 8 | import com.facebook.react.bridge.LifecycleEventListener; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 11 | import com.facebook.react.bridge.ReactMethod; 12 | 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | import java.util.HashSet; 16 | 17 | public class AdSettingsManager extends ReactContextBaseJavaModule implements LifecycleEventListener { 18 | 19 | final static private String TAG = AdSettingsManager.class.getName(); 20 | 21 | private HashSet mTestDeviceHashes = new HashSet<>(); 22 | private boolean mIsChildDirected = false; 23 | private String mMediationService = null; 24 | private String mUrlPrefix = null; 25 | 26 | public AdSettingsManager(ReactApplicationContext reactContext) { 27 | super(reactContext); 28 | reactContext.addLifecycleEventListener(this); 29 | } 30 | 31 | @Override 32 | public String getName() { 33 | return "CTKAdSettingsManager"; 34 | } 35 | 36 | @ReactMethod 37 | public void addTestDevice(String deviceHash) { 38 | AdSettings.addTestDevice(deviceHash); 39 | mTestDeviceHashes.add(deviceHash); 40 | } 41 | 42 | @ReactMethod 43 | public void clearTestDevices() { 44 | AdSettings.clearTestDevices(); 45 | mTestDeviceHashes.clear(); 46 | } 47 | 48 | @ReactMethod 49 | public void setLogLevel(String logLevel) { 50 | Log.w(TAG, "This method is not supported on Android"); 51 | } 52 | 53 | @ReactMethod 54 | public void setIsChildDirected(boolean isChildDirected) { 55 | AdSettings.setIsChildDirected(isChildDirected); 56 | mIsChildDirected = isChildDirected; 57 | } 58 | 59 | @ReactMethod 60 | public void setMediationService(String mediationService) { 61 | AdSettings.setMediationService(mediationService); 62 | mMediationService = mediationService; 63 | } 64 | 65 | @ReactMethod 66 | public void setUrlPrefix(String urlPrefix) { 67 | AdSettings.setUrlPrefix(urlPrefix); 68 | mUrlPrefix = urlPrefix; 69 | } 70 | 71 | private void restoreSettings() { 72 | for (String hash: mTestDeviceHashes) { 73 | AdSettings.addTestDevice(hash); 74 | } 75 | 76 | AdSettings.setIsChildDirected(mIsChildDirected); 77 | AdSettings.setMediationService(mMediationService); 78 | AdSettings.setUrlPrefix(mUrlPrefix); 79 | } 80 | 81 | private void clearSettings() { 82 | AdSettings.clearTestDevices(); 83 | AdSettings.setIsChildDirected(false); 84 | AdSettings.setMediationService(null); 85 | AdSettings.setUrlPrefix(null); 86 | } 87 | 88 | @Override 89 | public void onHostResume() { 90 | restoreSettings(); 91 | } 92 | 93 | @Override 94 | public void onHostPause() { 95 | clearSettings(); 96 | } 97 | 98 | @Override 99 | public void onHostDestroy() { 100 | clearSettings(); 101 | } 102 | 103 | @Override 104 | public Map getConstants() { 105 | final Map constants = new HashMap<>(); 106 | SharedPreferences sp = getReactApplicationContext().getSharedPreferences("FBAdPrefs", 0); 107 | String deviceHashedId = sp.getString("deviceIdHash", null); 108 | 109 | constants.put("currentDeviceHash", deviceHashedId); 110 | 111 | return constants; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXInterstitialAdManager.m: -------------------------------------------------------------------------------- 1 | #import "EXInterstitialAdManager.h" 2 | #import "EXUnversioned.h" 3 | 4 | #import 5 | #import 6 | #import 7 | 8 | @interface EXInterstitialAdManager () 9 | 10 | @property (nonatomic, strong) RCTPromiseResolveBlock resolve; 11 | @property (nonatomic, strong) RCTPromiseRejectBlock reject; 12 | @property (nonatomic, strong) FBInterstitialAd *interstitialAd; 13 | @property (nonatomic, strong) UIViewController *adViewController; 14 | @property (nonatomic) bool didClick; 15 | @property (nonatomic) bool isBackground; 16 | 17 | @end 18 | 19 | @implementation EXInterstitialAdManager 20 | 21 | @synthesize bridge = _bridge; 22 | 23 | RCT_EXPORT_MODULE(CTKInterstitialAdManager) 24 | 25 | - (void)setBridge:(RCTBridge *)bridge 26 | { 27 | _bridge = bridge; 28 | 29 | [[NSNotificationCenter defaultCenter] addObserver:self 30 | selector:@selector(bridgeDidForeground:) 31 | name:EX_UNVERSIONED(@"EXKernelBridgeDidForegroundNotification") 32 | object:self.bridge]; 33 | 34 | [[NSNotificationCenter defaultCenter] addObserver:self 35 | selector:@selector(bridgeDidBackground:) 36 | name:EX_UNVERSIONED(@"EXKernelBridgeDidBackgroundNotification") 37 | object:self.bridge]; 38 | } 39 | 40 | RCT_EXPORT_METHOD( 41 | showAd:(NSString *)placementId 42 | resolver:(RCTPromiseResolveBlock)resolve 43 | rejecter:(RCTPromiseRejectBlock)reject 44 | ) 45 | { 46 | RCTAssert(_resolve == nil && _reject == nil, @"Only one `showAd` can be called at once"); 47 | RCTAssert(_isBackground == false, @"`showAd` can be called only when experience is running in foreground"); 48 | // if (![EXFacebook facebookAppIdFromNSBundle]) { 49 | // RCTLogWarn(@"No Facebook app id is specified. Facebook ads may have undefined behavior."); 50 | // } 51 | 52 | _resolve = resolve; 53 | _reject = reject; 54 | 55 | _interstitialAd = [[FBInterstitialAd alloc] initWithPlacementID:placementId]; 56 | _interstitialAd.delegate = self; 57 | // [EXUtil performSynchronouslyOnMainThread:^{ 58 | [self->_interstitialAd loadAd]; 59 | // }]; 60 | } 61 | 62 | #pragma mark - FBInterstitialAdDelegate 63 | 64 | - (void)interstitialAdDidLoad:(__unused FBInterstitialAd *)interstitialAd 65 | { 66 | [_interstitialAd showAdFromRootViewController:RCTPresentedViewController()]; 67 | } 68 | 69 | - (void)interstitialAd:(FBInterstitialAd *)interstitialAd didFailWithError:(NSError *)error 70 | { 71 | _reject(@"E_FAILED_TO_LOAD", [error localizedDescription], error); 72 | 73 | [self cleanUpAd]; 74 | } 75 | 76 | - (void)interstitialAdDidClick:(FBInterstitialAd *)interstitialAd 77 | { 78 | _didClick = true; 79 | } 80 | 81 | - (void)interstitialAdDidClose:(FBInterstitialAd *)interstitialAd 82 | { 83 | _resolve(@(_didClick)); 84 | 85 | [self cleanUpAd]; 86 | } 87 | 88 | - (void)bridgeDidForeground:(NSNotification *)notification 89 | { 90 | _isBackground = false; 91 | 92 | if (_adViewController) { 93 | [RCTPresentedViewController() presentViewController:_adViewController animated:NO completion:nil]; 94 | _adViewController = nil; 95 | } 96 | } 97 | 98 | - (void)bridgeDidBackground:(NSNotification *)notification 99 | { 100 | _isBackground = true; 101 | 102 | if (_interstitialAd) { 103 | _adViewController = RCTPresentedViewController(); 104 | [_adViewController dismissViewControllerAnimated:NO completion:nil]; 105 | } 106 | } 107 | 108 | - (void)cleanUpAd 109 | { 110 | _reject = nil; 111 | _resolve = nil; 112 | _interstitialAd = nil; 113 | _adViewController = nil; 114 | _didClick = false; 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXAdSettingsManager.m: -------------------------------------------------------------------------------- 1 | #import "EXAdSettingsManager.h" 2 | #import "EXUnversioned.h" 3 | 4 | //#import 5 | #import 6 | #import 7 | @import FBAudienceNetwork; 8 | 9 | @implementation RCTConvert (EXNativeAdView) 10 | 11 | RCT_ENUM_CONVERTER(FBAdLogLevel, (@{ 12 | @"none": @(FBAdLogLevelNone), 13 | @"debug": @(FBAdLogLevelDebug), 14 | @"verbose": @(FBAdLogLevelVerbose), 15 | @"warning": @(FBAdLogLevelWarning), 16 | @"notification": @(FBAdLogLevelNotification), 17 | @"error": @(FBAdLogLevelError), 18 | }), FBAdLogLevelLog, integerValue) 19 | 20 | @end 21 | 22 | @interface EXAdSettingsManager () 23 | 24 | @property (nonatomic) BOOL isChildDirected; 25 | @property (nonatomic, strong) NSString *mediationService; 26 | @property (nonatomic, strong) NSString *urlPrefix; 27 | @property (nonatomic) FBAdLogLevel logLevel; 28 | @property (nonatomic, strong) NSMutableArray *testDevices; 29 | 30 | @end 31 | 32 | @implementation EXAdSettingsManager 33 | 34 | @synthesize bridge = _bridge; 35 | 36 | RCT_EXPORT_MODULE(CTKAdSettingsManager) 37 | 38 | - (instancetype)init { 39 | if (self = [super init]) { 40 | _testDevices = [NSMutableArray new]; 41 | _urlPrefix = @""; 42 | _mediationService = @""; 43 | } 44 | return self; 45 | } 46 | 47 | + (BOOL)requiresMainQueueSetup 48 | { 49 | return NO; 50 | } 51 | 52 | - (void)setBridge:(RCTBridge *)bridge 53 | { 54 | _bridge = bridge; 55 | 56 | [[NSNotificationCenter defaultCenter] addObserver:self 57 | selector:@selector(bridgeDidForeground:) 58 | name:EX_UNVERSIONED(@"EXKernelBridgeDidForegroundNotification") 59 | object:self.bridge]; 60 | 61 | [[NSNotificationCenter defaultCenter] addObserver:self 62 | selector:@selector(bridgeDidBackground:) 63 | name:EX_UNVERSIONED(@"EXKernelBridgeDidBackgroundNotification") 64 | object:self.bridge]; 65 | } 66 | 67 | RCT_EXPORT_METHOD(addTestDevice:(NSString *)deviceHash) 68 | { 69 | [FBAdSettings addTestDevice:deviceHash]; 70 | [_testDevices addObject:deviceHash]; 71 | } 72 | 73 | RCT_EXPORT_METHOD(clearTestDevices) 74 | { 75 | [FBAdSettings clearTestDevices]; 76 | [_testDevices removeAllObjects]; 77 | } 78 | 79 | RCT_EXPORT_METHOD(setLogLevel:(FBAdLogLevel)logLevel) 80 | { 81 | [FBAdSettings setLogLevel:logLevel]; 82 | _logLevel = logLevel; 83 | } 84 | 85 | RCT_EXPORT_METHOD(setIsChildDirected:(BOOL)isDirected) 86 | { 87 | [FBAdSettings setIsChildDirected:isDirected]; 88 | _isChildDirected = isDirected; 89 | } 90 | 91 | RCT_EXPORT_METHOD(setMediationService:(NSString *)mediationService) 92 | { 93 | [FBAdSettings setMediationService:mediationService]; 94 | _mediationService = mediationService; 95 | } 96 | 97 | RCT_EXPORT_METHOD(setUrlPrefix:(NSString *)urlPrefix) 98 | { 99 | [FBAdSettings setUrlPrefix:urlPrefix]; 100 | _urlPrefix = urlPrefix; 101 | } 102 | 103 | - (void)bridgeDidForeground:(NSNotification *)notification 104 | { 105 | [FBAdSettings setIsChildDirected:_isChildDirected]; 106 | [FBAdSettings setMediationService:_mediationService]; 107 | [FBAdSettings setUrlPrefix:_urlPrefix]; 108 | [FBAdSettings setLogLevel:_logLevel]; 109 | [FBAdSettings addTestDevices:_testDevices]; 110 | } 111 | 112 | - (void)bridgeDidBackground:(NSNotification *)notification 113 | { 114 | [FBAdSettings setIsChildDirected:NO]; 115 | [FBAdSettings setMediationService:@""]; 116 | [FBAdSettings setUrlPrefix:@""]; 117 | [FBAdSettings setLogLevel:FBAdLogLevelLog]; 118 | [FBAdSettings clearTestDevices]; 119 | } 120 | 121 | - (void)dealloc 122 | { 123 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 124 | } 125 | 126 | - (NSDictionary *)constantsToExport 127 | { 128 | return @{ @"currentDeviceHash": [FBAdSettings testDeviceHash] }; 129 | } 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /NativeAdsManager.js: -------------------------------------------------------------------------------- 1 | import {NativeModules, NativeEventEmitter} from 'react-native'; 2 | import {EventEmitter, EmitterSubscription} from 'fbemitter'; 3 | 4 | const {CTKNativeAdManager, CTKNativeAdEmitter} = NativeModules; 5 | 6 | const nativeAdEmitter = new NativeEventEmitter(CTKNativeAdEmitter); 7 | 8 | const EVENT_DID_BECOME_VALID = 'AdsManagerDidBecomeValid'; 9 | 10 | type AdManagerCachePolicy = 'none' | 'icon' | 'image' | 'all'; 11 | 12 | class NativeAdsManager { 13 | /** {@string} with placement id of ads **/ 14 | placementId: string; 15 | 16 | /** {@number} of ads to request at once **/ 17 | adsToRequest: number; 18 | 19 | /** {@boolean} indicating whether AdsManager is ready to serve ads **/ 20 | isValid: boolean = false; 21 | 22 | /** {@EventEmitter} used for sending out updates **/ 23 | eventEmitter: EventEmitter = new EventEmitter(); 24 | 25 | static async registerViewsForInteractionAsync(nativeAdViewTag: number, 26 | mediaViewTag: number, 27 | adIconViewTag: number, 28 | clickable: Array) { 29 | if(adIconViewTag>0 && mediaViewTag>0 ){ 30 | clickable.push(mediaViewTag,adIconViewTag) 31 | }else if(mediaViewTag > 0){ 32 | clickable.push(mediaViewTag) 33 | }else if(adIconViewTag > 0){ 34 | clickable.push(adIconViewTag) 35 | } 36 | console.log(nativeAdViewTag); 37 | console.log(mediaViewTag); 38 | console.log(adIconViewTag); 39 | console.log(clickable); 40 | let result = await CTKNativeAdManager.registerViewsForInteraction( 41 | nativeAdViewTag, 42 | mediaViewTag, 43 | adIconViewTag, 44 | clickable); 45 | return result 46 | } 47 | 48 | /** 49 | * Creates an instance of AdsManager with a given placementId and adsToRequest. 50 | * Default number of ads to request is `10`. 51 | * 52 | * AdsManager will become loading ads immediately 53 | */ 54 | constructor(placementId: string, adsToRequest: number = 10) { 55 | this.placementId = placementId; 56 | this.adsToRequest = adsToRequest; 57 | 58 | this._listenForStateChanges(); 59 | 60 | CTKNativeAdManager.init(placementId, adsToRequest); 61 | } 62 | 63 | /** 64 | * Listens for AdManager state changes and updates internal state. When it changes, 65 | * callers will be notified of a change 66 | */ 67 | _listenForStateChanges() { 68 | nativeAdEmitter.addListener('CTKNativeAdsManagersChanged', managers => { 69 | const isValidNew = managers[this.placementId]; 70 | const isValid = this.isValid; 71 | 72 | if (isValid !== isValidNew && isValidNew) { 73 | this.isValid = true; 74 | this.eventEmitter.emit(EVENT_DID_BECOME_VALID); 75 | } 76 | }); 77 | } 78 | 79 | /** 80 | * Used to listening for state changes 81 | * 82 | * If manager already became valid, it will call the function w/o registering 83 | * handler for events 84 | */ 85 | onAdsLoaded(func: Function): EmitterSubscription { 86 | if (this.isValid) { 87 | setTimeout(func); 88 | return { 89 | remove: () => { 90 | }, 91 | }; 92 | } 93 | 94 | return this.eventEmitter.once(EVENT_DID_BECOME_VALID, func); 95 | } 96 | 97 | /** 98 | * Disables auto refreshing for this native ad manager 99 | */ 100 | disableAutoRefresh() { 101 | CTKNativeAdManager.disableAutoRefresh(this.placementId); 102 | } 103 | 104 | /** 105 | * Set the native ads manager caching policy. This controls which media from 106 | * the native ads are cached before the onAdsLoaded is called. 107 | * The default is to not block on caching. 108 | */ 109 | setMediaCachePolicy(cachePolicy: AdManagerCachePolicy) { 110 | CTKNativeAdManager.setMediaCachePolicy(this.placementId, cachePolicy); 111 | } 112 | 113 | toJSON() { 114 | return this.placementId; 115 | } 116 | } 117 | 118 | export default NativeAdsManager; 119 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook/EXNativeAdManager.m: -------------------------------------------------------------------------------- 1 | #import "EXNativeAdManager.h" 2 | #import "EXNativeAdView.h" 3 | #import "EXNativeAdEmitter.h" 4 | 5 | #import 6 | #import 7 | #import 8 | #import 9 | #import 10 | #import 11 | 12 | @implementation RCTConvert (EXNativeAdView) 13 | 14 | RCT_ENUM_CONVERTER(FBNativeAdsCachePolicy, (@{ 15 | @"none": @(FBNativeAdsCachePolicyNone), 16 | @"all": @(FBNativeAdsCachePolicyAll), 17 | }), FBNativeAdsCachePolicyNone, integerValue) 18 | 19 | @end 20 | 21 | @interface EXNativeAdManager () 22 | 23 | @property (nonatomic, strong) NSMutableDictionary *adsManagers; 24 | @property (nonatomic, strong) NSString *myAdChoiceViewPlacementId; 25 | 26 | @end 27 | 28 | @implementation EXNativeAdManager 29 | 30 | RCT_EXPORT_MODULE(CTKNativeAdManager) 31 | 32 | @synthesize bridge = _bridge; 33 | 34 | - (instancetype)init 35 | { 36 | self = [super init]; 37 | if (self) { 38 | _adsManagers = [NSMutableDictionary new]; 39 | } 40 | return self; 41 | } 42 | 43 | + (BOOL)requiresMainQueueSetup 44 | { 45 | return NO; 46 | } 47 | 48 | RCT_EXPORT_METHOD(registerViewsForInteraction:(nonnull NSNumber *)nativeAdViewTag 49 | mediaViewTag:(nonnull NSNumber *)mediaViewTag 50 | adIconViewTag:(nonnull NSNumber *)adIconViewTag 51 | clickableViewsTags:(nonnull NSArray *)tags 52 | resolve:(RCTPromiseResolveBlock)resolve 53 | reject:(RCTPromiseRejectBlock)reject) 54 | { 55 | [_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { 56 | FBMediaView *mediaView = nil; 57 | FBAdIconView *adIconView = nil; 58 | EXNativeAdView *nativeAdView = nil; 59 | 60 | if ([viewRegistry objectForKey:mediaViewTag] == nil) { 61 | reject(@"E_NO_VIEW_FOR_TAG", @"Could not find mediaView", nil); 62 | return; 63 | } 64 | 65 | if ([viewRegistry objectForKey:nativeAdViewTag] == nil) { 66 | reject(@"E_NO_NATIVEAD_VIEW", @"Could not find nativeAdView", nil); 67 | return; 68 | } 69 | 70 | if ([[viewRegistry objectForKey:mediaViewTag] isKindOfClass:[FBMediaView class]]) { 71 | mediaView = (FBMediaView *)[viewRegistry objectForKey:mediaViewTag]; 72 | } else { 73 | reject(@"E_INVALID_VIEW_CLASS", @"View returned for passed media view tag is not an instance of FBMediaView", nil); 74 | return; 75 | } 76 | 77 | if ([[viewRegistry objectForKey:nativeAdViewTag] isKindOfClass:[EXNativeAdView class]]) { 78 | nativeAdView = (EXNativeAdView *)[viewRegistry objectForKey:nativeAdViewTag]; 79 | } else { 80 | reject(@"E_INVALID_VIEW_CLASS", @"View returned for passed native ad view tag is not an instance of EXNativeAdView", nil); 81 | return; 82 | } 83 | 84 | if ([viewRegistry objectForKey:adIconViewTag]) { 85 | if ([[viewRegistry objectForKey:adIconViewTag] isKindOfClass:[FBAdIconView class]]) { 86 | adIconView = (FBAdIconView *)[viewRegistry objectForKey:adIconViewTag]; 87 | } else { 88 | reject(@"E_INVALID_VIEW_CLASS", @"View returned for passed ad icon view tag is not an instance of FBAdIconView", nil); 89 | return; 90 | } 91 | } 92 | 93 | NSMutableArray *clickableViews = [NSMutableArray new]; 94 | for (id tag in tags) { 95 | if ([viewRegistry objectForKey:tag]) { 96 | [clickableViews addObject:[viewRegistry objectForKey:tag]]; 97 | } else { 98 | reject(@"E_INVALID_VIEW_TAG", [NSString stringWithFormat:@"Could not find view for tag: %@", [tag stringValue]], nil); 99 | return; 100 | } 101 | } 102 | 103 | [nativeAdView registerViewsForInteraction:mediaView adIcon:adIconView clickableViews:clickableViews]; 104 | resolve(@[]); 105 | }]; 106 | } 107 | 108 | RCT_EXPORT_METHOD(init:(NSString *)placementId withAdsToRequest:(nonnull NSNumber *)adsToRequest) 109 | { 110 | 111 | FBNativeAdsManager *adsManager = [[FBNativeAdsManager alloc] initWithPlacementID:placementId 112 | forNumAdsRequested:[adsToRequest intValue]]; 113 | 114 | _myAdChoiceViewPlacementId = placementId; 115 | 116 | [adsManager setDelegate:self]; 117 | 118 | [adsManager loadAds]; 119 | 120 | [_adsManagers setValue:adsManager forKey:placementId]; 121 | } 122 | 123 | RCT_EXPORT_METHOD(setMediaCachePolicy:(NSString*)placementId cachePolicy:(FBNativeAdsCachePolicy)cachePolicy) 124 | { 125 | [_adsManagers[placementId] setMediaCachePolicy:cachePolicy]; 126 | } 127 | 128 | RCT_EXPORT_METHOD(disableAutoRefresh:(NSString*)placementId) 129 | { 130 | [_adsManagers[placementId] disableAutoRefresh]; 131 | } 132 | 133 | - (FBNativeAdsManager *) getFBAdsManager:(NSString *)placementId 134 | { 135 | return _adsManagers[placementId]; 136 | } 137 | 138 | - (void)nativeAdsLoaded 139 | { 140 | NSMutableDictionary *adsManagersState = [NSMutableDictionary new]; 141 | 142 | [_adsManagers enumerateKeysAndObjectsUsingBlock:^(NSString* key, FBNativeAdsManager* adManager, __unused BOOL* stop) { 143 | [adsManagersState setValue:@([adManager isValid]) forKey:key]; 144 | }]; 145 | 146 | EXNativeAdEmitter *nativeAdEmitter = [_bridge moduleForClass:[EXNativeAdEmitter class]]; 147 | [nativeAdEmitter sendManagersState:adsManagersState]; 148 | } 149 | 150 | - (void)nativeAdsFailedToLoadWithError:(NSError *)errors 151 | { 152 | // @todo handle errors here 153 | } 154 | 155 | - (UIView *)view 156 | { 157 | return [[EXNativeAdView alloc] initWithBridge:_bridge]; 158 | } 159 | 160 | RCT_EXPORT_VIEW_PROPERTY(onAdLoaded, RCTBubblingEventBlock) 161 | RCT_CUSTOM_VIEW_PROPERTY(adsManager, NSString, EXNativeAdView) 162 | { 163 | view.nativeAd = [_adsManagers[json] nextNativeAd]; 164 | } 165 | 166 | @end 167 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /android/app/src/main/java/suraj/tiwari/reactnativefbads/NativeAdManager.java: -------------------------------------------------------------------------------- 1 | package suraj.tiwari.reactnativefbads; 2 | 3 | import android.util.Log; 4 | import android.view.View; 5 | 6 | import com.facebook.ads.AdError; 7 | import com.facebook.ads.AdIconView; 8 | import com.facebook.ads.MediaView; 9 | import com.facebook.ads.NativeAdsManager; 10 | import com.facebook.react.bridge.Arguments; 11 | import com.facebook.react.bridge.Promise; 12 | import com.facebook.react.bridge.ReactApplicationContext; 13 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 14 | import com.facebook.react.bridge.ReactMethod; 15 | import com.facebook.react.bridge.ReadableArray; 16 | import com.facebook.react.bridge.UiThreadUtil; 17 | import com.facebook.react.bridge.WritableMap; 18 | import com.facebook.react.modules.core.RCTNativeAppEventEmitter; 19 | import com.facebook.react.uimanager.IllegalViewOperationException; 20 | import com.facebook.react.uimanager.NativeViewHierarchyManager; 21 | import com.facebook.react.uimanager.UIBlock; 22 | import com.facebook.react.uimanager.UIManagerModule; 23 | 24 | import java.util.ArrayList; 25 | import java.util.HashMap; 26 | import java.util.List; 27 | import java.util.Map; 28 | 29 | public class NativeAdManager extends ReactContextBaseJavaModule implements NativeAdsManager.Listener { 30 | /** 31 | * @{Map} with all registered fb ads managers 32 | **/ 33 | private Map mAdsManagers = new HashMap<>(); 34 | 35 | public NativeAdManager(ReactApplicationContext reactContext) { 36 | super(reactContext); 37 | } 38 | 39 | @Override 40 | public String getName() { 41 | return "CTKNativeAdManager"; 42 | } 43 | 44 | /** 45 | * Initialises native ad manager for a given placement id and ads to request. 46 | * This method is run on the UI thread 47 | * 48 | * @param placementId 49 | * @param adsToRequest 50 | */ 51 | @ReactMethod 52 | public void init(final String placementId, final int adsToRequest) { 53 | final ReactApplicationContext reactContext = this.getReactApplicationContext(); 54 | 55 | UiThreadUtil.runOnUiThread(new Runnable() { 56 | @Override 57 | public void run() { 58 | final NativeAdsManager adsManager = new NativeAdsManager(reactContext, placementId, adsToRequest); 59 | 60 | adsManager.setListener(NativeAdManager.this); 61 | 62 | mAdsManagers.put(placementId, adsManager); 63 | 64 | adsManager.loadAds(); 65 | } 66 | }); 67 | } 68 | 69 | /** 70 | * Disables auto refresh 71 | * 72 | * @param placementId 73 | */ 74 | @ReactMethod 75 | public void disableAutoRefresh(String placementId) { 76 | mAdsManagers.get(placementId).disableAutoRefresh(); 77 | } 78 | 79 | /** 80 | * Sets media cache policy 81 | * 82 | * @param placementId 83 | * @param cachePolicy 84 | */ 85 | @ReactMethod 86 | public void setMediaCachePolicy(String placementId, String cachePolicy) { 87 | Log.w("NativeAdManager", "This method is not supported on Android"); 88 | } 89 | 90 | /** 91 | * Called when one of the registered ads managers loads ads. Sends state of all 92 | * managers back to JS 93 | */ 94 | @Override 95 | public void onAdsLoaded() { 96 | WritableMap adsManagersState = Arguments.createMap(); 97 | 98 | for (String key : mAdsManagers.keySet()) { 99 | NativeAdsManager adsManager = mAdsManagers.get(key); 100 | adsManagersState.putBoolean(key, adsManager.isLoaded()); 101 | } 102 | 103 | sendAppEvent("CTKNativeAdsManagersChanged", adsManagersState); 104 | } 105 | 106 | @Override 107 | public void onAdError(AdError adError) { 108 | // @todo handle errors here 109 | } 110 | 111 | /** 112 | * Returns FBAdsManager for a given placement id 113 | * 114 | * @param placementId 115 | * @return 116 | */ 117 | public NativeAdsManager getFBAdsManager(String placementId) { 118 | return mAdsManagers.get(placementId); 119 | } 120 | 121 | /** 122 | * Helper for sending events back to Javascript. 123 | * 124 | * @param eventName 125 | * @param params 126 | */ 127 | private void sendAppEvent(String eventName, Object params) { 128 | ReactApplicationContext context = this.getReactApplicationContext(); 129 | 130 | if (context == null || !context.hasActiveCatalystInstance()) { 131 | return; 132 | } 133 | 134 | context 135 | .getJSModule(RCTNativeAppEventEmitter.class) 136 | .emit(eventName, params); 137 | } 138 | 139 | @ReactMethod 140 | public void registerViewsForInteraction(final int adTag, 141 | final int mediaViewTag, 142 | final int adIconViewTag, 143 | final ReadableArray clickableViewsTags, 144 | final Promise promise) { 145 | getReactApplicationContext().getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() { 146 | @Override 147 | public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) { 148 | try { 149 | NativeAdView nativeAdView = null; 150 | MediaView mediaView = null; 151 | AdIconView adIconView = null; 152 | 153 | if (adTag != -1) { 154 | nativeAdView = (NativeAdView) nativeViewHierarchyManager.resolveView(adTag); 155 | } 156 | 157 | if (mediaViewTag != -1) { 158 | mediaView = (MediaView) nativeViewHierarchyManager.resolveView(mediaViewTag); 159 | } 160 | 161 | if (adIconViewTag != -1) { 162 | adIconView = (AdIconView) nativeViewHierarchyManager.resolveView(adIconViewTag); 163 | } 164 | 165 | List clickableViews = new ArrayList<>(); 166 | 167 | for (int i = 0; i < clickableViewsTags.size(); ++i) { 168 | View view = nativeViewHierarchyManager.resolveView(clickableViewsTags.getInt(i)); 169 | clickableViews.add(view); 170 | } 171 | 172 | Log.w("NativeAdManagerClickableViewsTags", Integer.toString(clickableViewsTags.size())); 173 | Log.w("NativeAdManagerClickableViews", Integer.toString(clickableViews.size()) ); 174 | 175 | nativeAdView.registerViewsForInteraction(mediaView, adIconView, clickableViews); 176 | promise.resolve(null); 177 | 178 | } catch (ClassCastException e) { 179 | promise.reject("E_CANNOT_CAST", e); 180 | } catch (IllegalViewOperationException e) { 181 | promise.reject("E_INVALID_TAG_ERROR", e); 182 | } catch (NullPointerException e) { 183 | promise.reject("E_NO_NATIVE_AD_VIEW", e); 184 | } catch (Exception e) { 185 | promise.reject("E_AD_REGISTER_ERROR", e); 186 | } 187 | } 188 | }); 189 | } 190 | } -------------------------------------------------------------------------------- /withNativeAd.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {EmitterSubscription} from 'fbemitter'; 3 | import {requireNativeComponent, findNodeHandle, Text, View} from 'react-native'; 4 | 5 | import AdsManager from './NativeAdsManager'; 6 | import {NativeAdIconView} from './AdIconViewManager'; 7 | import {NativeMediaView} from './MediaViewManager'; 8 | import {MediaView, AdIconView, AdChoicesView} from './index' 9 | 10 | const NativeAdView = requireNativeComponent('CTKNativeAd', null); 11 | 12 | type NativeAd = { 13 | advertiserName: ?string, 14 | bodyText: ?string, 15 | callToActionText: ?string, 16 | headline: ?string, 17 | linkDescription: ?string, 18 | promotedTranslation: ?string, 19 | socialContext: ?string, 20 | sponsoredTranslation: ?string, 21 | translation: ?string, 22 | }; 23 | 24 | type NativeAdWrapperState = { 25 | ad: ?NativeAd, 26 | canRequestAds: boolean, 27 | mediaViewNodeHandle: number, 28 | adIconViewNodeHandle: number, 29 | clickableChildren: Set, 30 | }; 31 | 32 | type NativeAdWrapperProps = { 33 | adsManager: AdsManager, 34 | onAdLoaded?: ?(?NativeAd) => void, 35 | adChoicePosition?: ?string 36 | }; 37 | 38 | type MultipleRegisterablesContextValueType = { 39 | unregister: (React.Node => void) | null, 40 | register: (React.Node => void) | null, 41 | }; 42 | 43 | type RegisterableContextValueType = { 44 | register: (React.Node => void) | null, 45 | unregister: (() => void) | null, 46 | }; 47 | 48 | export type TriggerableContextValueType = MultipleRegisterablesContextValueType; 49 | export type AdIconViewContextValueType = RegisterableContextValueType; 50 | export type MediaViewContextValueType = RegisterableContextValueType; 51 | 52 | /** 53 | * Higher order function that wraps given `Component` and provides `nativeAd` as a prop 54 | * 55 | * In case of an empty ad or adsManager not yet ready for displaying ads, null will be 56 | * returned instead of a component provided. 57 | */ 58 | 59 | const defaultValue = {register: null, unregister: null}; 60 | 61 | export const TriggerableContext = React.createContext(defaultValue); 62 | export const MediaViewContext = React.createContext(defaultValue); 63 | export const AdIconViewContext = React.createContext(defaultValue); 64 | 65 | export default (Component: React.ComponentType) => 66 | class NativeAdWrapper extends React.Component { 67 | _subscription: ?EmitterSubscription; 68 | _nativeAdViewRef: ?NativeAdView; 69 | _registerFunctionsForTriggerables: TriggerableContextValueType; 70 | _registerFunctionsForMediaView: MediaViewContextValueType; 71 | _registerFunctionsForAdIconView: AdIconViewContextValueType; 72 | _clickableChildrenNodeHandles: { [React.Node]: number }; 73 | 74 | constructor(props: NativeAdWrapperProps & T) { 75 | super(props); 76 | 77 | this._registerFunctionsForTriggerables = { 78 | register: this._registerClickableChild, 79 | unregister: this._unregisterClickableChild, 80 | }; 81 | 82 | this._registerFunctionsForMediaView = { 83 | unregister: this._unregisterMediaView, 84 | register: this._registerMediaView, 85 | }; 86 | 87 | this._registerFunctionsForAdIconView = { 88 | unregister: this._unregisterAdIconView, 89 | register: this._registerAdIconView, 90 | }; 91 | 92 | this._clickableChildrenNodeHandles = {}; 93 | 94 | this.state = { 95 | ad: null, 96 | // iOS requires a nonnull value 97 | mediaViewNodeHandle: -1, 98 | adIconViewNodeHandle: -1, 99 | clickableChildren: new Set(), 100 | canRequestAds: false 101 | }; 102 | } 103 | 104 | /** 105 | * On init, register for updates on `adsManager` to know when it becomes available 106 | */ 107 | componentDidMount() { 108 | this._subscription = this.props.adsManager.onAdsLoaded(() => 109 | this.setState({canRequestAds: true}) 110 | ); 111 | } 112 | 113 | componentDidUpdate(prevProps: NativeAdWrapperProps, prevState: NativeAdWrapperState) { 114 | if (this.state.mediaViewNodeHandle !== -1 || this.state.adIconViewNodeHandle !== -1 || [...this.state.clickableChildren] > 0) { 115 | const mediaViewNodeHandleChanged = 116 | this.state.mediaViewNodeHandle !== prevState.mediaViewNodeHandle; 117 | const adIconViewNodeHandleChanged = 118 | this.state.adIconViewNodeHandle !== prevState.adIconViewNodeHandle; 119 | const clickableChildrenChanged = [...prevState.clickableChildren].filter( 120 | child => !this.state.clickableChildren.has(child) 121 | ); 122 | if (mediaViewNodeHandleChanged || adIconViewNodeHandleChanged || clickableChildrenChanged) { 123 | console.log('update'); 124 | AdsManager.registerViewsForInteractionAsync( 125 | findNodeHandle(this._nativeAdViewRef), 126 | this.state.mediaViewNodeHandle, 127 | this.state.adIconViewNodeHandle, 128 | [...this.state.clickableChildren] 129 | ); 130 | } 131 | } 132 | } 133 | 134 | /** 135 | * Clear subscription when component goes off screen 136 | */ 137 | componentWillUnmount() { 138 | if (this._subscription) { 139 | this._subscription.remove(); 140 | } 141 | } 142 | 143 | _registerMediaView = (mediaView: NativeMediaView) => 144 | this.setState({mediaViewNodeHandle: findNodeHandle(mediaView)}); 145 | _unregisterMediaView = () => this.setState({mediaViewNodeHandle: -1}); 146 | 147 | _registerAdIconView = (adIconView: NativeAdIconView) => 148 | this.setState({adIconViewNodeHandle: findNodeHandle(adIconView)}); 149 | _unregisterAdIconView = () => this.setState({adIconViewNodeHandle: -1}); 150 | 151 | _registerClickableChild = (child: React.Node) => { 152 | this._clickableChildrenNodeHandles[child] = findNodeHandle(child); 153 | this.setState({clickableChildren: this.state.clickableChildren.add(findNodeHandle(child))}); 154 | }; 155 | 156 | _unregisterClickableChild = (child: React.Node) => { 157 | this.setState(({clickableChildren}) => { 158 | const newClickableChildren = new Set(clickableChildren); 159 | newClickableChildren.delete(this._clickableChildrenNodeHandles[child]); 160 | delete this._clickableChildrenNodeHandles[child]; 161 | return {clickableChildren: newClickableChildren}; 162 | }); 163 | }; 164 | 165 | _handleAdUpdated = () => this.props.onAdLoaded && this.props.onAdLoaded(this.state.ad); 166 | 167 | _handleAdLoaded = ({nativeEvent}: { nativeEvent: NativeAd }) => { 168 | this.setState({ad: nativeEvent}, this._handleAdUpdated); 169 | }; 170 | 171 | _handleNativeAdViewMount = (ref: ?NativeAdView) => { 172 | this._nativeAdViewRef = ref; 173 | }; 174 | 175 | renderAdComponent(componentProps: T) { 176 | const {adsManager,adChoicePosition,expandable} = this.props; 177 | if (this.state.ad) { 178 | return ( 179 | 180 | 181 | 182 | {/* In case of no AdIconView or MediaView in Custom layout, 183 | It will keep Triggerable component Functional */} 184 | 185 | 186 | 187 | 190 | 191 | 192 | 193 | ); 194 | } 195 | return null; 196 | } 197 | 198 | render() { 199 | const {adsManager, ...props} = this.props; 200 | delete props.onAdLoaded; 201 | 202 | if (!this.state.canRequestAds) { 203 | return null; 204 | } 205 | 206 | return ( 207 | 211 | {this.renderAdComponent(props)} 212 | 213 | ); 214 | } 215 | }; -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | react-native-ads-facebook [![npm version](https://badge.fury.io/js/react-native-ads-facebook.svg)](https://badge.fury.io/js/react-native-ads-facebook) 2 | ============ 3 | 4 | [![Facebook Ads](./images/threed_mockup_fbNativeads.png)](https://developers.facebook.com/products/app-monetization) 5 | 6 | **Facebook Audience SDK** integration for React Native, available on iOS and Android. Features native, interstitial and banner ads. 7 | 8 | ## Table of Contents 9 | 10 | - [Installation](#installation) 11 | - [Install Javascript packages](#1-install-javascript-packages) 12 | - [Configure native projects](#2-configure-native-projects) 13 | - [iOS](#21-ios) 14 | - [Android](#22-android) 15 | - [Usage](#usage) 16 | - [Interstitial Ads](#interstitial-ads) 17 | - [1. Showing ad](#1-showing-ad) 18 | - [Native Ads](#native-ads) 19 | - [1. Creating AdsManager](#1-creating-adsmanager) 20 | - [2. Making ad component](#2-making-ad-component) 21 | - [3. Rendering an ad](#3-rendering-an-ad) 22 | - [Banner View](#bannerview) 23 | - [1. Showing ad](#1-showing-ad-1) 24 | - [API](#api) 25 | - [NativeAdsManager](#nativeadsmanager) 26 | - [disableAutoRefresh](#disableautorefresh) 27 | - [setMediaCachePolicy](#setmediacachepolicy) 28 | - [InterstitialAdManager](#interstitialadmanager) 29 | - [showAd](#showad) 30 | - [AdSettings](#adsettings) 31 | - [currentDeviceHash](#currentdevicehash) 32 | - [addTestDevice](#addtestdevice) 33 | - [clearTestDevices](#cleartestdevices) 34 | - [setLogLevel](#setloglevel) 35 | - [setIsChildDirected](#setischilddirected) 36 | - [setMediationService](#setmediationservice) 37 | - [setUrlPrefix](#seturlprefix) 38 | - [Running example](#running-example) 39 | - [Install dependencies](#1-install-dependencies) 40 | - [Start packager](#2-start-packager) 41 | - [Run it on iOS / Android](#3-run-it-on-ios--android) 42 | - [Credits](#credits) 43 | 44 | ## Installation 45 | 46 | ### 1. Install Javascript packages 47 | Install JavaScript packages: 48 | 49 | ```bash 50 | $ react-native install react-native-ads-facebook 51 | ``` 52 | 53 | ### 2. Configure native projects 54 | 55 | The react-native-ads-facebook has been automatically linked for you, the next step will be downloading and linking the native Facebook SDK for both platforms. 56 | 57 | #### 2.1 iOS 58 | 59 | Make sure you have the latest Xcode installed. Open the .xcodeproj in Xcode found in the ios subfolder from your project's root directory. Now, follow all the steps in the [Getting Started Guide for Facebook SDK](https://developers.facebook.com/docs/ios/getting-started) for iOS. Along with FBSDKCoreKit.framework, don't forget to import FBAudienceNetwork.framework. 60 | 61 | Next, **follow steps 1 and 3** from the [Getting Started Guide for Facebook Audience](https://developers.facebook.com/docs/audience-network/getting-started). Once you have created the `placement id`, write it down and continue to next section. 62 | 63 | ### IOS Install Instruction 64 | ``` 65 | cd ios 66 | pod init 67 | pod 'FBAudienceNetwork','4.99.0' // In your pod file add this 68 | pod install 69 | ``` 70 | after that open `{projectname.xcworkspace}` 71 | 72 | ##### **If Build failed on release see [#3](https://github.com/Suraj-Tiwari/react-native-ads-facebook/issues/3)** 73 | ##### Suggestion: **Use CocaPods If you want to save your time fixing random issue** 74 | 75 | #### 2.2. Android 76 | 77 | If you are using [`react-native-fbsdk`](https://github.com/facebook/react-native-fbsdk) you can follow their installation instructions. Otherwise, please follow official [Getting Started Guide for Facebook SDK](https://developers.facebook.com/docs/android/getting-started). 78 | 79 | ### Interstitial Ads 80 | 81 | Interstitial Ad is a type of an ad that displays full screen with media content. It has a dismiss button as well as the clickable area that takes user outside of your app. 82 | 83 | 84 | 85 | They are displayed over your root view with a single, imperative call. 86 | 87 | #### 1. Showing ad 88 | 89 | In order to show an ad, you have to import `InterstitialAdManager` and call `showAd` on it supplying it a placementId identifier, as in the below example: 90 | 91 | ```js 92 | import { InterstitialAdManager } from 'react-native-ads-facebook'; 93 | 94 | InterstitialAdManager.showAd(placementId) 95 | .then(didClick => {}) 96 | .catch(error => {}) 97 | ``` 98 | 99 | Method returns a promise that will be rejected when an error occurs during a call (e.g. no fill from ad server or network error) and resolve when user either dimisses or interacts with the displayed ad. 100 | 101 | ### Native Ads 102 | 103 | Native Ad is a type of an ad that matches the form and function of your React Native interface. 104 | 105 | 106 | 107 | #### 1. Creating AdsManager 108 | 109 | In order to start rendering your custom native ads within your app, you have to construct 110 | a `NativeAdManager` that is responsible for caching and fetching ads as you request them. 111 | 112 | ```js 113 | import { NativeAdsManager } from 'react-native-ads-facebook'; 114 | 115 | const adsManager = new NativeAdsManager(placementId, numberOfAdsToRequest); 116 | ``` 117 | 118 | The constructor accepts two parameters: 119 | - `placementId` - which is an unique identifier describing your ad units, 120 | - `numberOfAdsToRequest` - which is a number of ads to request by ads manager at a time 121 | 122 | #### 2. Making ad component 123 | 124 | After creating `adsManager` instance, next step is to wrap an arbitrary component that you want to 125 | use for rendering your custom advertises with a `withNativeAd` wrapper. 126 | 127 | It's a higher order component that passes `nativeAd` via props to a wrapped component allowing 128 | you to actually render an ad! 129 | 130 | The `nativeAd` object can contain the following properties: 131 | 132 | - `advertiserName` - The name of the Facebook Page or mobile app that represents the business running each ad. 133 | - `headline` - The headline that the advertiser entered when they created their ad. This is usually the ad's main title. 134 | - `linkDescription` - Additional information that the advertiser may have entered. 135 | - `translation` - The word 'ad', translated into the language based upon Facebook app language setting. 136 | - `promotedTranslation` - The word 'promoted', translated into the language based upon Facebook app language setting. 137 | - `sponsoredTranslation` - The word 'sponsored', translated into the language based upon Facebook app language setting. 138 | - `bodyText` - Ad body 139 | - `callToActionText` - Call to action phrase, e.g. - "Install Now" 140 | - `socialContext` - social context for the Ad, for example "Over half a million users" 141 | 142 | 143 | ** Note: ** Don't use more than one MediaView/AdIconView component within one native ad. 144 | 145 | ** Note: ** To make any text `Triggerable` wrap it in use only component 146 | 147 | 148 | ```js 149 | import { AdIconView,MediaView,TriggerableView } from 'react-native-ads-facebook'; 150 | class AdComponent extends React.Component { 151 | render() { 152 | return ( 153 | 154 | 155 | 156 | 157 | {this.props.nativeAd.description} 158 | 159 | 160 | ); 161 | } 162 | } 163 | 164 | export default withNativeAd(AdComponent); 165 | ``` 166 | 167 | #### 3. Rendering an ad 168 | 169 | Finally, you can render your wrapped component from previous step and pass it `adsManager` 170 | of your choice. 171 | 172 | ##### Adchoice position props 173 | 174 | | prop | default | required | params | description | 175 | |------------------|----------|----------|-----------------------------------------------------------------------------|----------------------------------| 176 | | adsManager | null | true | `const adsManager = new NativeAdsManager(placementId, numberOfAdsToRequest)` | Set Placement id for native ad | 177 | | adChoicePosition | topRight | false | `topLeft , topRight , bottomLeft , bottomRight` | Set Ad choice position | 178 | | expandable | true | false | BOOLEAN | IOS only set Adchoice expandable | 179 | 180 | ```js 181 | class MainApp extends React.Component { 182 | render() { 183 | return ( 184 | 185 | 186 | 187 | ); 188 | } 189 | } 190 | ``` 191 | 192 | ### BannerView 193 | 194 | BannerView is a component that allows you to display native banners (know as *AdView*). 195 | 196 | Banners are available in 3 sizes: 197 | - `standard` (BANNER_HEIGHT_50) 198 | - `large` (BANNER_HEIGHT_90) 199 | - `rectangle` (RECTANGLE_HEIGHT_250) 200 | 201 | #### 1. Showing ad 202 | 203 | In order to show an ad, you have to first import it `BannerView` from the package: 204 | 205 | ```js 206 | import { BannerView } from 'react-native-ads-facebook'; 207 | ``` 208 | 209 | Later in your app, you can render it like below: 210 | 211 | ```js 212 | function ViewWithBanner(props) { 213 | return ( 214 | 215 | console.log('click')} 219 | onError={(err) => console.log('error', err)} 220 | /> 221 | 222 | ); 223 | } 224 | ``` 225 | 226 | ## API 227 | 228 | ### NativeAdsManager 229 | 230 | Provides a mechanism to fetch a set of ads and then use them within your application. The native ads manager supports giving out as many ads as needed by cloning over the set of ads it got back from the server which can be useful for feed scenarios. It's a wrapper for [`FBNativeAdsManager`](https://developers.facebook.com/docs/reference/ios/current/class/FBNativeAdsManager/) 231 | 232 | #### disableAutoRefresh 233 | 234 | By default the native ads manager will refresh its ads periodically. This does not mean that any ads which are shown in the application's UI will be refreshed but simply that requesting next native ads to render may return new ads at different times. This method disables that functionality. 235 | 236 | ```js 237 | adsManager.disableAutoRefresh(); 238 | ``` 239 | 240 | #### setMediaCachePolicy 241 | 242 | Sets the native ads manager caching policy. This controls which media from the native ads are cached before being displayed. The default is to not block on caching. 243 | 244 | ```js 245 | adsManager.setMediaCachePolicy('none' | 'icon' | 'image' | 'all'); 246 | ``` 247 | 248 | **Note:** This method is a noop on Android 249 | 250 | ### InterstitialAdManager 251 | 252 | ```js 253 | import { InterstitialAdManager } from 'react-native-ads-facebook'; 254 | ``` 255 | 256 | InterstitialAdManager is a manager that allows you to display interstitial ads within your app with a single call. 257 | 258 | #### showAd 259 | 260 | Loads an interstitial ad asynchronously and shows it full screen by attaching a view onto the current root view 261 | controller. 262 | 263 | ```js 264 | InterstitialAdManager.showAd('placementId') 265 | .then(...) 266 | .catch(...); 267 | ``` 268 | 269 | Promise will be rejected when there's an error loading ads from Facebook Audience network. It will resolve with a 270 | `boolean` indicating whether user didClick an ad or not. 271 | 272 | On Android you have to add following activity to *AndroidManifest.xml* 273 | ```xml 274 | 277 | ``` 278 | 279 | **Note:** There can be only one `showAd` call being performed at a time. Otherwise, an error will be thrown. 280 | 281 | ### AdSettings 282 | 283 | ```js 284 | import { AdSettings } from 'react-native-ads-facebook'; 285 | ``` 286 | 287 | AdSettings contains global settings for all ad controls. 288 | 289 | #### currentDeviceHash 290 | 291 | Constant which contains current device's hash id. 292 | 293 | #### addTestDevice 294 | 295 | Registers given device to receive test ads. When you run app on simulator, it should automatically get added. Use it 296 | to receive test ads in development mode on a standalone phone. Hash of the current device can be obtained from a 297 | debug log or `AdSettings.currentDeviceHash` constant. 298 | 299 | All devices should be specified before any other action takes place, like [`AdsManager`](#nativeadsmanager) gets created. 300 | 301 | ```js 302 | AdSettings.addTestDevice('hash'); 303 | ``` 304 | 305 | #### clearTestDevices 306 | 307 | Clears all previously set test devices. If you want your ads to respect newly set config, you'll have to destroy and create 308 | an instance of AdsManager once again. 309 | 310 | ```js 311 | AdSettings.clearTestDevices(); 312 | ``` 313 | 314 | #### setLogLevel 315 | 316 | Sets current SDK log level. 317 | 318 | ```js 319 | AdSettings.setLogLevel('none' | 'debug' | 'verbose' | 'warning' | 'error' | 'notification'); 320 | ``` 321 | 322 | **Note:** This method is a noop on Android. 323 | 324 | #### setIsChildDirected 325 | 326 | Configures the ad control for treatment as child-directed. 327 | 328 | ```js 329 | AdSettings.setIsChildDirected(true | false); 330 | ``` 331 | 332 | #### setMediationService 333 | 334 | If an ad provided service is mediating Audience Network in their sdk, it is required to set the name of the mediation service 335 | 336 | ```js 337 | AdSettings.setMediationService('foobar'); 338 | ``` 339 | 340 | #### setUrlPrefix 341 | 342 | Sets the url prefix to use when making ad requests. 343 | 344 | ```js 345 | AdSettings.setUrlPrefix('...'); 346 | ``` 347 | 348 | **Note:** This method should never be used in production 349 | 350 | ## Running example 351 | 352 | In order to see ads you will have to create your own `placementId` and use it instead of the one provided in the examples. 353 | 354 | ## Switching from react-native-fbads 355 | 356 | ```bash 357 | 358 | //IOS Note: Remove previously integrated FbAudienceNetwork.framework for react-native-fbads 359 | 360 | react-native uninstall react-native-fbads 361 | 362 | react-native install react-native-ads-facebook 363 | 364 | change 'react-native-fbads' to 'react-native-ads-facebook' in your import dependencies. 365 | 366 | //IOS NOTE: use pod to install ReactNativeAdsFacebook 367 | 368 | ``` 369 | 370 | 371 | 372 | ### Credits 373 | 374 | Some of the API explanations were borrowed from Facebook SDK documentation. 375 | 376 | Documentation taken from react-native-fbads 377 | 378 | Image Credit [threed.io](http://threed.io/) 379 | -------------------------------------------------------------------------------- /ios/ReactNativeAdsFacebook.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D2AFD378211B15F300580DF0 /* EXNativeAdManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD366211B15F300580DF0 /* EXNativeAdManager.m */; }; 11 | D2AFD379211B15F300580DF0 /* EXNativeAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD368211B15F300580DF0 /* EXNativeAdView.m */; }; 12 | D2AFD37A211B15F300580DF0 /* EXBannerViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD36A211B15F300580DF0 /* EXBannerViewManager.m */; }; 13 | D2AFD37B211B15F300580DF0 /* EXBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD36E211B15F300580DF0 /* EXBannerView.m */; }; 14 | D2AFD37C211B15F300580DF0 /* EXNativeMediaViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD370211B15F300580DF0 /* EXNativeMediaViewManager.m */; }; 15 | D2AFD37D211B15F300580DF0 /* EXAdIconViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD372211B15F300580DF0 /* EXAdIconViewManager.m */; }; 16 | D2AFD37E211B15F300580DF0 /* EXAdSettingsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD374211B15F300580DF0 /* EXAdSettingsManager.m */; }; 17 | D2AFD37F211B15F300580DF0 /* EXInterstitialAdManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD375211B15F300580DF0 /* EXInterstitialAdManager.m */; }; 18 | D2AFD380211B15F300580DF0 /* EXNativeAdEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD376211B15F300580DF0 /* EXNativeAdEmitter.m */; }; 19 | D2AFD6642122392E00580DF0 /* AdChoiceManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD6632122392E00580DF0 /* AdChoiceManager.m */; }; 20 | D2AFD6742122B89100580DF0 /* AdChoiceView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2AFD6722122B89100580DF0 /* AdChoiceView.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXCopyFilesBuildPhase section */ 24 | D2AFD331211B138E00580DF0 /* CopyFiles */ = { 25 | isa = PBXCopyFilesBuildPhase; 26 | buildActionMask = 2147483647; 27 | dstPath = "include/$(PRODUCT_NAME)"; 28 | dstSubfolderSpec = 16; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXCopyFilesBuildPhase section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | D2AFD333211B138E00580DF0 /* libReactNativeAdsFacebook.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReactNativeAdsFacebook.a; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | D2AFD366211B15F300580DF0 /* EXNativeAdManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXNativeAdManager.m; sourceTree = ""; }; 38 | D2AFD367211B15F300580DF0 /* EXNativeAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXNativeAdView.h; sourceTree = ""; }; 39 | D2AFD368211B15F300580DF0 /* EXNativeAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXNativeAdView.m; sourceTree = ""; }; 40 | D2AFD369211B15F300580DF0 /* EXNativeAdEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXNativeAdEmitter.h; sourceTree = ""; }; 41 | D2AFD36A211B15F300580DF0 /* EXBannerViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXBannerViewManager.m; sourceTree = ""; }; 42 | D2AFD36B211B15F300580DF0 /* EXNativeMediaViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXNativeMediaViewManager.h; sourceTree = ""; }; 43 | D2AFD36C211B15F300580DF0 /* EXBannerViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXBannerViewManager.h; sourceTree = ""; }; 44 | D2AFD36D211B15F300580DF0 /* EXBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXBannerView.h; sourceTree = ""; }; 45 | D2AFD36E211B15F300580DF0 /* EXBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXBannerView.m; sourceTree = ""; }; 46 | D2AFD36F211B15F300580DF0 /* EXInterstitialAdManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXInterstitialAdManager.h; sourceTree = ""; }; 47 | D2AFD370211B15F300580DF0 /* EXNativeMediaViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXNativeMediaViewManager.m; sourceTree = ""; }; 48 | D2AFD371211B15F300580DF0 /* EXAdIconViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXAdIconViewManager.h; sourceTree = ""; }; 49 | D2AFD372211B15F300580DF0 /* EXAdIconViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXAdIconViewManager.m; sourceTree = ""; }; 50 | D2AFD373211B15F300580DF0 /* EXAdSettingsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXAdSettingsManager.h; sourceTree = ""; }; 51 | D2AFD374211B15F300580DF0 /* EXAdSettingsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXAdSettingsManager.m; sourceTree = ""; }; 52 | D2AFD375211B15F300580DF0 /* EXInterstitialAdManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXInterstitialAdManager.m; sourceTree = ""; }; 53 | D2AFD376211B15F300580DF0 /* EXNativeAdEmitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EXNativeAdEmitter.m; sourceTree = ""; }; 54 | D2AFD377211B15F300580DF0 /* EXNativeAdManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXNativeAdManager.h; sourceTree = ""; }; 55 | D2AFD6602121FD8200580DF0 /* EXUnversioned.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EXUnversioned.h; sourceTree = ""; }; 56 | D2AFD6622122391200580DF0 /* AdChoiceManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AdChoiceManager.h; sourceTree = ""; }; 57 | D2AFD6632122392E00580DF0 /* AdChoiceManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AdChoiceManager.m; sourceTree = ""; }; 58 | D2AFD6722122B89100580DF0 /* AdChoiceView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdChoiceView.m; sourceTree = ""; }; 59 | D2AFD6732122B89100580DF0 /* AdChoiceView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdChoiceView.h; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | D2AFD330211B138E00580DF0 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | D2AFD32A211B138E00580DF0 = { 74 | isa = PBXGroup; 75 | children = ( 76 | D2AFD335211B138E00580DF0 /* ReactNativeAdsFacebook */, 77 | D2AFD334211B138E00580DF0 /* Products */, 78 | ); 79 | sourceTree = ""; 80 | }; 81 | D2AFD334211B138E00580DF0 /* Products */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | D2AFD333211B138E00580DF0 /* libReactNativeAdsFacebook.a */, 85 | ); 86 | name = Products; 87 | sourceTree = ""; 88 | }; 89 | D2AFD335211B138E00580DF0 /* ReactNativeAdsFacebook */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | D2AFD6732122B89100580DF0 /* AdChoiceView.h */, 93 | D2AFD6722122B89100580DF0 /* AdChoiceView.m */, 94 | D2AFD371211B15F300580DF0 /* EXAdIconViewManager.h */, 95 | D2AFD372211B15F300580DF0 /* EXAdIconViewManager.m */, 96 | D2AFD373211B15F300580DF0 /* EXAdSettingsManager.h */, 97 | D2AFD374211B15F300580DF0 /* EXAdSettingsManager.m */, 98 | D2AFD36D211B15F300580DF0 /* EXBannerView.h */, 99 | D2AFD36E211B15F300580DF0 /* EXBannerView.m */, 100 | D2AFD36C211B15F300580DF0 /* EXBannerViewManager.h */, 101 | D2AFD36A211B15F300580DF0 /* EXBannerViewManager.m */, 102 | D2AFD36F211B15F300580DF0 /* EXInterstitialAdManager.h */, 103 | D2AFD375211B15F300580DF0 /* EXInterstitialAdManager.m */, 104 | D2AFD369211B15F300580DF0 /* EXNativeAdEmitter.h */, 105 | D2AFD376211B15F300580DF0 /* EXNativeAdEmitter.m */, 106 | D2AFD377211B15F300580DF0 /* EXNativeAdManager.h */, 107 | D2AFD366211B15F300580DF0 /* EXNativeAdManager.m */, 108 | D2AFD367211B15F300580DF0 /* EXNativeAdView.h */, 109 | D2AFD368211B15F300580DF0 /* EXNativeAdView.m */, 110 | D2AFD36B211B15F300580DF0 /* EXNativeMediaViewManager.h */, 111 | D2AFD370211B15F300580DF0 /* EXNativeMediaViewManager.m */, 112 | D2AFD6602121FD8200580DF0 /* EXUnversioned.h */, 113 | D2AFD6622122391200580DF0 /* AdChoiceManager.h */, 114 | D2AFD6632122392E00580DF0 /* AdChoiceManager.m */, 115 | ); 116 | path = ReactNativeAdsFacebook; 117 | sourceTree = ""; 118 | }; 119 | /* End PBXGroup section */ 120 | 121 | /* Begin PBXNativeTarget section */ 122 | D2AFD332211B138E00580DF0 /* ReactNativeAdsFacebook */ = { 123 | isa = PBXNativeTarget; 124 | buildConfigurationList = D2AFD33C211B138E00580DF0 /* Build configuration list for PBXNativeTarget "ReactNativeAdsFacebook" */; 125 | buildPhases = ( 126 | D2AFD32F211B138E00580DF0 /* Sources */, 127 | D2AFD330211B138E00580DF0 /* Frameworks */, 128 | D2AFD331211B138E00580DF0 /* CopyFiles */, 129 | ); 130 | buildRules = ( 131 | ); 132 | dependencies = ( 133 | ); 134 | name = ReactNativeAdsFacebook; 135 | productName = ReactNativeAdsFacebook; 136 | productReference = D2AFD333211B138E00580DF0 /* libReactNativeAdsFacebook.a */; 137 | productType = "com.apple.product-type.library.static"; 138 | }; 139 | /* End PBXNativeTarget section */ 140 | 141 | /* Begin PBXProject section */ 142 | D2AFD32B211B138E00580DF0 /* Project object */ = { 143 | isa = PBXProject; 144 | attributes = { 145 | LastUpgradeCheck = 0940; 146 | ORGANIZATIONNAME = "Suraj Tiwari "; 147 | TargetAttributes = { 148 | D2AFD332211B138E00580DF0 = { 149 | CreatedOnToolsVersion = 9.4; 150 | }; 151 | }; 152 | }; 153 | buildConfigurationList = D2AFD32E211B138E00580DF0 /* Build configuration list for PBXProject "ReactNativeAdsFacebook" */; 154 | compatibilityVersion = "Xcode 9.3"; 155 | developmentRegion = en; 156 | hasScannedForEncodings = 0; 157 | knownRegions = ( 158 | en, 159 | ); 160 | mainGroup = D2AFD32A211B138E00580DF0; 161 | productRefGroup = D2AFD334211B138E00580DF0 /* Products */; 162 | projectDirPath = ""; 163 | projectRoot = ""; 164 | targets = ( 165 | D2AFD332211B138E00580DF0 /* ReactNativeAdsFacebook */, 166 | ); 167 | }; 168 | /* End PBXProject section */ 169 | 170 | /* Begin PBXSourcesBuildPhase section */ 171 | D2AFD32F211B138E00580DF0 /* Sources */ = { 172 | isa = PBXSourcesBuildPhase; 173 | buildActionMask = 2147483647; 174 | files = ( 175 | D2AFD37C211B15F300580DF0 /* EXNativeMediaViewManager.m in Sources */, 176 | D2AFD380211B15F300580DF0 /* EXNativeAdEmitter.m in Sources */, 177 | D2AFD37E211B15F300580DF0 /* EXAdSettingsManager.m in Sources */, 178 | D2AFD378211B15F300580DF0 /* EXNativeAdManager.m in Sources */, 179 | D2AFD379211B15F300580DF0 /* EXNativeAdView.m in Sources */, 180 | D2AFD37D211B15F300580DF0 /* EXAdIconViewManager.m in Sources */, 181 | D2AFD37F211B15F300580DF0 /* EXInterstitialAdManager.m in Sources */, 182 | D2AFD6742122B89100580DF0 /* AdChoiceView.m in Sources */, 183 | D2AFD6642122392E00580DF0 /* AdChoiceManager.m in Sources */, 184 | D2AFD37A211B15F300580DF0 /* EXBannerViewManager.m in Sources */, 185 | D2AFD37B211B15F300580DF0 /* EXBannerView.m in Sources */, 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXSourcesBuildPhase section */ 190 | 191 | /* Begin XCBuildConfiguration section */ 192 | D2AFD33A211B138E00580DF0 /* Debug */ = { 193 | isa = XCBuildConfiguration; 194 | buildSettings = { 195 | ALWAYS_SEARCH_USER_PATHS = NO; 196 | CLANG_ANALYZER_NONNULL = YES; 197 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 198 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 199 | CLANG_CXX_LIBRARY = "libc++"; 200 | CLANG_ENABLE_MODULES = YES; 201 | CLANG_ENABLE_OBJC_ARC = YES; 202 | CLANG_ENABLE_OBJC_WEAK = YES; 203 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 204 | CLANG_WARN_BOOL_CONVERSION = YES; 205 | CLANG_WARN_COMMA = YES; 206 | CLANG_WARN_CONSTANT_CONVERSION = YES; 207 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 208 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 209 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 210 | CLANG_WARN_EMPTY_BODY = YES; 211 | CLANG_WARN_ENUM_CONVERSION = YES; 212 | CLANG_WARN_INFINITE_RECURSION = YES; 213 | CLANG_WARN_INT_CONVERSION = YES; 214 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 215 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 216 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 217 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 218 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 219 | CLANG_WARN_STRICT_PROTOTYPES = YES; 220 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 221 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 222 | CLANG_WARN_UNREACHABLE_CODE = YES; 223 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 224 | CODE_SIGN_IDENTITY = "iPhone Developer"; 225 | COPY_PHASE_STRIP = NO; 226 | DEBUG_INFORMATION_FORMAT = dwarf; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | ENABLE_TESTABILITY = YES; 229 | GCC_C_LANGUAGE_STANDARD = gnu11; 230 | GCC_DYNAMIC_NO_PIC = NO; 231 | GCC_NO_COMMON_BLOCKS = YES; 232 | GCC_OPTIMIZATION_LEVEL = 0; 233 | GCC_PREPROCESSOR_DEFINITIONS = ( 234 | "DEBUG=1", 235 | "$(inherited)", 236 | ); 237 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 238 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 239 | GCC_WARN_UNDECLARED_SELECTOR = YES; 240 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 241 | GCC_WARN_UNUSED_FUNCTION = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 244 | MACH_O_TYPE = staticlib; 245 | MTL_ENABLE_DEBUG_INFO = YES; 246 | ONLY_ACTIVE_ARCH = YES; 247 | SDKROOT = iphoneos; 248 | }; 249 | name = Debug; 250 | }; 251 | D2AFD33B211B138E00580DF0 /* Release */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | ALWAYS_SEARCH_USER_PATHS = NO; 255 | CLANG_ANALYZER_NONNULL = YES; 256 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 257 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 258 | CLANG_CXX_LIBRARY = "libc++"; 259 | CLANG_ENABLE_MODULES = YES; 260 | CLANG_ENABLE_OBJC_ARC = YES; 261 | CLANG_ENABLE_OBJC_WEAK = YES; 262 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 263 | CLANG_WARN_BOOL_CONVERSION = YES; 264 | CLANG_WARN_COMMA = YES; 265 | CLANG_WARN_CONSTANT_CONVERSION = YES; 266 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 267 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 268 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 269 | CLANG_WARN_EMPTY_BODY = YES; 270 | CLANG_WARN_ENUM_CONVERSION = YES; 271 | CLANG_WARN_INFINITE_RECURSION = YES; 272 | CLANG_WARN_INT_CONVERSION = YES; 273 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 274 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 275 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 276 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 277 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 278 | CLANG_WARN_STRICT_PROTOTYPES = YES; 279 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 280 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 281 | CLANG_WARN_UNREACHABLE_CODE = YES; 282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 283 | CODE_SIGN_IDENTITY = "iPhone Developer"; 284 | COPY_PHASE_STRIP = NO; 285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 286 | ENABLE_NS_ASSERTIONS = NO; 287 | ENABLE_STRICT_OBJC_MSGSEND = YES; 288 | GCC_C_LANGUAGE_STANDARD = gnu11; 289 | GCC_NO_COMMON_BLOCKS = YES; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 297 | MACH_O_TYPE = staticlib; 298 | MTL_ENABLE_DEBUG_INFO = NO; 299 | SDKROOT = iphoneos; 300 | VALIDATE_PRODUCT = YES; 301 | }; 302 | name = Release; 303 | }; 304 | D2AFD33D211B138E00580DF0 /* Debug */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | CODE_SIGN_STYLE = Automatic; 308 | DEVELOPMENT_TEAM = W3VSH3LGL7; 309 | FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../../ios/Pods/FBAudienceNetwork/"; 310 | OTHER_LDFLAGS = "-ObjC"; 311 | PRODUCT_NAME = "$(TARGET_NAME)"; 312 | SKIP_INSTALL = YES; 313 | TARGETED_DEVICE_FAMILY = "1,2"; 314 | }; 315 | name = Debug; 316 | }; 317 | D2AFD33E211B138E00580DF0 /* Release */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | CODE_SIGN_STYLE = Automatic; 321 | DEVELOPMENT_TEAM = W3VSH3LGL7; 322 | FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../../ios/Pods/FBAudienceNetwork/"; 323 | OTHER_LDFLAGS = "-ObjC"; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SKIP_INSTALL = YES; 326 | TARGETED_DEVICE_FAMILY = "1,2"; 327 | }; 328 | name = Release; 329 | }; 330 | /* End XCBuildConfiguration section */ 331 | 332 | /* Begin XCConfigurationList section */ 333 | D2AFD32E211B138E00580DF0 /* Build configuration list for PBXProject "ReactNativeAdsFacebook" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | D2AFD33A211B138E00580DF0 /* Debug */, 337 | D2AFD33B211B138E00580DF0 /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | D2AFD33C211B138E00580DF0 /* Build configuration list for PBXNativeTarget "ReactNativeAdsFacebook" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | D2AFD33D211B138E00580DF0 /* Debug */, 346 | D2AFD33E211B138E00580DF0 /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | /* End XCConfigurationList section */ 352 | }; 353 | rootObject = D2AFD32B211B138E00580DF0 /* Project object */; 354 | } 355 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright © 2007 Free Software Foundation, Inc. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 10 | 11 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. 12 | 13 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 14 | 15 | To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. 16 | 17 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 18 | 19 | Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. 20 | 21 | For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. 22 | 23 | Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. 24 | 25 | Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. 26 | 27 | The precise terms and conditions for copying, distribution and modification follow. 28 | 29 | TERMS AND CONDITIONS 30 | 0. Definitions. 31 | “This License” refers to version 3 of the GNU General Public License. 32 | 33 | “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 34 | 35 | “The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. 36 | 37 | To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. 38 | 39 | A “covered work” means either the unmodified Program or a work based on the Program. 40 | 41 | To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 42 | 43 | To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 44 | 45 | An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 46 | 47 | 1. Source Code. 48 | The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. 49 | 50 | A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 51 | 52 | The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 53 | 54 | The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. 55 | 56 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 57 | 58 | The Corresponding Source for a work in source code form is that same work. 59 | 60 | 2. Basic Permissions. 61 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 62 | 63 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 64 | 65 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 66 | 67 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 68 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 69 | 70 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 71 | 72 | 4. Conveying Verbatim Copies. 73 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 74 | 75 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 76 | 77 | 5. Conveying Modified Source Versions. 78 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 79 | 80 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 81 | b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. 82 | c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 83 | d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 84 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 85 | 86 | 6. Conveying Non-Source Forms. 87 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 88 | 89 | a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 90 | b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 91 | c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 92 | d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 93 | e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 94 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 95 | 96 | A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 97 | 98 | “Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 99 | 100 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 101 | 102 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 103 | 104 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 105 | 106 | 7. Additional Terms. 107 | “Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 108 | 109 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 110 | 111 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 112 | 113 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 114 | b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 115 | c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 116 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 117 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 118 | f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 119 | All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 120 | 121 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 122 | 123 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 124 | 125 | 8. Termination. 126 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 127 | 128 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 129 | 130 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 131 | 132 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 133 | 134 | 9. Acceptance Not Required for Having Copies. 135 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 136 | 137 | 10. Automatic Licensing of Downstream Recipients. 138 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 139 | 140 | An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 141 | 142 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 143 | 144 | 11. Patents. 145 | A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. 146 | 147 | A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 148 | 149 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 150 | 151 | In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 152 | 153 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 154 | 155 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 156 | 157 | A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 158 | 159 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 160 | 161 | 12. No Surrender of Others' Freedom. 162 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 163 | 164 | 13. Use with the GNU Affero General Public License. 165 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 166 | 167 | 14. Revised Versions of this License. 168 | The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 169 | 170 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. 171 | 172 | If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 173 | 174 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 175 | 176 | 15. Disclaimer of Warranty. 177 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 178 | 179 | 16. Limitation of Liability. 180 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 181 | 182 | 17. Interpretation of Sections 15 and 16. 183 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 184 | 185 | END OF TERMS AND CONDITIONS 186 | 187 | How to Apply These Terms to Your New Programs 188 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. 189 | 190 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. 191 | 192 | 193 | Copyright (C) 194 | 195 | This program is free software: you can redistribute it and/or modify 196 | it under the terms of the GNU General Public License as published by 197 | the Free Software Foundation, either version 3 of the License, or 198 | (at your option) any later version. 199 | 200 | This program is distributed in the hope that it will be useful, 201 | but WITHOUT ANY WARRANTY; without even the implied warranty of 202 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 203 | GNU General Public License for more details. 204 | 205 | You should have received a copy of the GNU General Public License 206 | along with this program. If not, see . 207 | Also add information on how to contact you by electronic and paper mail. 208 | 209 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 210 | 211 | React-Native-Ads-Facebook Copyright (C) 2018 Suraj Tiwari 212 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 213 | This is free software, and you are welcome to redistribute it 214 | under certain conditions; type `show c' for details. 215 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. 216 | 217 | You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . 218 | 219 | The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . 220 | --------------------------------------------------------------------------------