Skip to content

AdsPostX/rnadspostx

Repository files navigation

rnadspostx

AdsPostX offers a react native package designed to help you integrate AdsPostX into your react native mobile application within minutes and start generating more revenue and increasing sales.

Installation

npm install rnadspostx

Usage

  1. Init AdsPostX:
 const sdkId = 'a359ddi39903994f';
 AdsPostXPlugin.init(sdkId, (response) => {
     /* if response is true, mean init call is success.
        otherwise you will get error with response.*/
    }
});
  1. Load AdsPostX Offers:
const payload = { firstname: 'john', country: 'US' };

AdsPostXPlugin.load((response) => {
  /*
    if response is 'true' mean offer loaded successfully,
    else check 'error' field for error while loading offers.
    */
}, payload);
  1. Show AdsPostX Offers:
// values used here are just for demo purpose, use actual values when you are integrating SDK.

const showOptions = {
  position: {
    topMargin: 5.0,
    rightMargin: 5.0,
    bottomMargin: 5.0,
    leftMargin: 5.0,
  },
  styles: {
    transparent: true,
    type: 'popup', // OR 'fullscreen',
  },
  callbacks: {
    showCallback: () => {
      console.log('Show callback called');
    },
    errorCallback: (event) => {
      console.log('Error callback called:', event);
    },
    dismissCallback: () => {
      console.log('Dismiss callback called');
    },
  },
};

AdsPostXPlugin.show(showOptions);
  1. Get Offers
const sdkId = 'YOUR_SDK_ID';
const payload = {
  country: 'USA',
  firstname: 'Dev',
  creative: '1',
  dev: '1',
};

try {
  const responseData = await AdsPostXPlugin.getOffers(sdkId, payload);

  // to access offers
  if (responseData.status) {
    const offers = responseData.response.data.offers;
  }
} catch (error) {
  // Handle any errors that occurred during the getOffers call...
}
  1. Set Environment
AdsPostXPlugin.setEnvironment(0); // for 'live' environment.

OR;

AdsPostXPlugin.setEnvironment(1); // for 'test' environment.
  1. Set Debug Log
AdsPostx.setDebugLog(true);
OR;
AdsPostx.setDebugLog(false);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library