/react-native-amazon-tam

React Native wrapper around the Amazon Transparent Ad Marketplace SDK

Primary LanguageJava

react-native-amazon-tam

This library is a thin wrapper around the iOS and Android Amazon SDK for Amazon Publisher Services (APS). This library requires an APS account and the installation of the Amazon iOS and Android SDK. Before installing this library please follow Amazon's install instructions here.

NOTE It's important that you save the Amazon iOS SDK to [your project's name]/ios/Frameworks/. That is where this package looks for Amazon's DTBiOSSDK.framework.

Getting started

$ npm install react-native-amazon-tam --save

Mostly automatic installation

$ react-native link react-native-amazon-tam

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-amazon-tam and add RNAmazonTAM.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNAmazonTAM.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.krazylabs.rnamazontam.RNAmazonTAMPackage; to the imports at the top of the file
  • Add new RNAmazonTAMPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-amazon-tam'
    project(':react-native-amazon-tam').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-amazon-tam/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      implementation project(':react-native-amazon-tam')
    

Usage

Banner Ad

To request a banner ad from APS, use requestBannerAd(width: Int, height: Int, slotUUID: String).

import { requestBannerAd } from 'react-native-amazon-tam';

const ad = await requestBannerAd(320, 50, 'your-slot-uuid');

Interstitial Ad

To request a banner ad from APS, use requestInterstitialAd(slotUUID: String).

import { requestInterstitialAd } from 'react-native-amazon-tam';

const ad = await requestInterstitialAd('your-slot-uuid');