I'm trying to provide a Google subscription service using the react-native-iap
API.
I'm trying to enter data into the developerPayload
value to split the service.
const result = await requestSubscription(
sku,
false,
offerToken,
developerPayload,
);
ChatGPT told me to use it as above. However, there is no function in their API that takes the arguments as listed.
How can I use it?
API version :12.10.2
Thank you for read my question :)
You should handle the Android and iOS separately on your own business logic.
You can simply check the Platform.OS === 'android'
and then use the IAP.requestSubscription
depends on this and write two different methods for these.
Here is a basic example for you:
Android Example:
export async const purchaseAndroidSubscription(sku: string, offerToken: string){
await IAP.requestSubscription({
sku,
subscriptionOffers: [
{
sku,
offerToken,
},
],
});
}
iOS one:
export async const purchaseAppleSubscription(sku: IOSSku){
await IAP.clearTransactionIOS();
await IAP.requestSubscription({ sku });
}
You should customize/change as your need.
Also, I strongly suggest you to read the whole documentation and check the IAPExample before doing these stuff. Only ChatGPT will not enough for this :)