Earn extra income with the mobile app?

Tram Ho

Earn extra income with the mobile app? This is a problem that has been discussed for a long time but still can not stop being hot? Which are developing trendy apps, which are apps combined with developing technology (AI, AR, …), security apps, On-demand apps, … ways to make money from mobile apps easier like In-app advertising or in-app-purchase, …

The title is flashy, that’s all, but today I’ll share how to integrate in-app-purchase with react-native.

I. Prepare

The first thing you need is already on google store developer account and apple app store and has public.

Library settings

yarn add react-native-iap

reac-native link react-native-iap

Before running ios you need to run cd ios && pod install && cd ..

II. Config

1. iOS

First you need to go to ItunesConnect and complete the Agreements, Tax and Bankings section.

Next we need to enable In-app-purchase on xcode so (if you do not see it, check if your account is already a develop account, or have it enabled on configuage)

Enable on console develop

Next you need to go to the latest version with state Ready to Submit on the Features tab and select In-App Purchases. Then fill in the products you have as shown below

Please note the name of the item, I will demo later and need it: non.consume.prod , point_1000 , point_5000

1. Android

Android is simpler than just signing in and app and adding your products https://play.google.com/apps/publish

Name of products: point_1000 , 10000_point , 5000_point

Add permissions in Manifest.xml

<uses-permission android:name="com.android.vending.BILLING" />

II. Setup code and test it

Because I only have a dev account on Android so I demo it on Android, ios you just need to enable in-app-purchase on xcode and add the product as above.

First you create a view with a button, when clicking on the product, pass that product id to get information about it on the store. Here I passed a product id is android.test.purchased, it is equivalent to the point_1000 , 10000_point , 5000_point above I said, I created it differently

Next need to configure a bit to check how we connect to the store, how payment errors

You should read the docs to read the Api to understand better

Finally, our processing function

If you do it right, it will look like me

Welcome to React Native 

Share the news now

Source : Viblo