AlexDisler / cordova-plugin-inapppurchase

A lightweight cordova plugin for in app purchases on iOS/Android
316 stars 192 forks source link

inAppPurchase object missing on Android in React project [SOLVED] #260

Closed walmink closed 5 years ago

walmink commented 5 years ago

I'm posting my issue and solution here, because I didn't found the answer anywhere else online.

Problem

You're using Cordova with CreateReactApp and your inAppPurchase object is accessible on iOS, but not on Android. You've checked everything: the cordova object does exist in the window, you wait until deviceReady and you've set up the billing key in the manifest file. What could be wrong?

Solution

If you are like me, you've tried every suggestion online but failed. You might want to check one stupid detail that I overlooked for hours:

The billing key should not be added the manifest.json file in the www folder, but to the one in the public folder. That's because the www folder is rebuilt every time you build your project. So you can add your billing key to www, but it will never make it into the build. Seems obvious now, but I overlooked it for the longest time...