Skip to main content

Initialization

The first step to integrate with Appmate SDK is to add the library to your app and initialize an instance of the Appmate. With Appmate SDK, you will be able to manage all the processes of Apple's IAP APIs through the single sdk. To integrate the Appmate, open a terminal inside your project directory and type the command below.

npm install --save react-native-appmate

For HMS users only, insertion of the code below is also needed. Navigate to your android project directory and add the code into your MainActivity.java file, inside MainActivity class. Then, it will expect some libraries to import.

@Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) {  super.onActivityResult(requestCode, resultCode, data);  AppmateModule.onActivityResult(requestCode, resultCode, data);}

In order to complete iOS installation, you need to install pods additionally. Navigate to your ios folder and run the command below.

pod install

In order to complete Android installation, you also need to figure out the Android gradle and proguard steps by following this guide step-by-step.

Creating Apps#

If you haven't created your apps at App Store Connect Console yet, please start by following this guide step-by-step.

If you haven't created your apps at Google Play Console and Huawei App Gallery Console yet, please start by following this guide step-by-step.

Configuration#

If you haven't done Google Store Configuration yet, please start by following this guide.

If you haven't done App Gallery Configuration yet, please start by following this guide.

If you haven't done App Store Configuration yet, please start by following this guide.

Creating Products#

If you haven't created any products for Android, please start by following this guide.

If you haven't created any products for iOS, please start by following this guide.

Requirements#

Minimum iOS target: iOS 11.0+

Minimum Android API Level: 19+

Initialization of Appmate#

Once you've added a dependency on the Appmate SDK, you have to set ApiKey initially. And you can set UserId and SandboxActive optionally. Appmate is a singleton class that you can create it once in your app and call by Appmate instance throughout your app.

We recommend you to set initial configurations in App.js file of your app or in home screen using useEffect hook. Appmate is the main class for communication between the Appmate SDK and the rest of your app.

note

You can retrieve ApiKey from Appmate console.

useEffect(() => {    PurchaseClient.setApiKey(apiKey)      .then((success) => {          if(success) {            // PurchaseClient.setSandboxActive(true)            //   .then()            //   .catch()          }      })      .catch(error => {          console.log(error.message)      });}, []);

Also you can retrieve userId from Appmate SDK regardless of you set a userId or a random userId is created.

PurchaseClient.getUserId()  .then((userId) => {      //Use your userId here. We recommend you to use useState hook to keep userId value.  })  .catch(error => {      console.log(error.message);  };