0.3.5 • Published 4 years ago

react-native-iap-redux v0.3.5

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

React Native IAP Redux

How to use

Configure

import ReactNativeIapRedux from 'react-native-iap-redux';

const config = {
  async_storage_key: 'purchases',
  redux_reducer_key: 'purchases',
  redux_action_type_load: 'LOAD_PURCHASES',
  redux_action_type_buy: 'BUY_PURCHASE',
};

export default new ReactNativeIapRedux(config);

Set up Reducer

import IapRedux from './iapRedux'

const rootReducer = combineReducers({
  [IapRedux.reducerKey]: IapRedux.reducer,
});

Define purchases somewhere

import IapRedux from './iapRedux'

export default {
  purchase1: new IapRedux.Purchase({ sku: 'com.purchase.example' })
}

Preload from AsyncStorage

import IapRedux from './iapRedux'
import store from './store';

await IapRedux.init(store)

Buy

async onPress(purchase) {
  if (!purchase.isAvailable()) {
    const info = await purchase.getInfo()
    Alert.alert(
      info.title,
      info.description,
      [
        {
          text: 'Cancel',
          style: 'cancel',
        },
        {
          text: `Buy for ${info.localizedPrice}`, onPress: () => purchase.buy()
        },
        {
          text: 'Restore purchases',
          onPress: () => IapRedux.restore(),
        },
      ]
    )
  }
}
0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago