Closed domuen closed 1 year ago
For Android, are you running on the Emulator? (It only works on physical devices). For Ios, what device/iOS version are you testing with? What Storekit mode are you using?
I am testing on physical devices. I am using an iPhone 13 on iOS 15 and Samsung S22 on android 12. I am not using StoreKit. I am going to create subscriptions to the ones I created on AppStore Connect. I can't use any of the methods though because initConnection
throws that exception
@babydough The thing that comes to mind is that you might be using setup({storekitMode: 'STOREKIT2_MODE'})
on a device with older iOS. Another option is that IAP purchases are not available on those devices. Are you able to purchase on other apps?
same thing was happening to me - after upgrading from version 6 - in my case the error was being thrown from calling flushFailedPurchasesCachedAsPendingAndroid
on ios
and on android it throws this error when calling clearProductsIOS
That makes sense. Thank you @LorienHW for your help
I am not calling the setup
, flushFailedPurchasesCachedAsPendingAndroid
or clearProductsIOS
methods at all. All I am doing is calling initConnection
in my useEffect in App.tsx on app launch, which is throwing that exception
Here is my entire App.tsx component
import React from "react";
...
export default () => {
const checkSubscription = async () => {
try {
const skus: string[] = Platform.OS === "ios" ?
["...", "..."] :
["...", "..."];
const subscriptions = await getSubscriptions(skus);
console.log(subscriptions);
} catch (e) {
console.error(e);
}
};
React.useEffect(() => {
initConnection()
.then((c) => console.log("connected: ", c))
.catch((e) => console.log("connection error:", e));
}, []);
return <React.Fragment>
...
</React.Fragment>
}
you might go into node_modules/react-native-iap/src/internal/platform.ts into the method checkNativeIOSAvailable
and see which condition is causing it to error - either !RNIapIos
or !isStorekit2Avaiable()
must be returning true. if RNIapIos
is not defined maybe the native module is not present for some reason. You can go in and put some console.log statements in that file and they will print out in your javascript console when you run it. Dumb question but you did run pod install right?
@LorienHW I just did what you said and logged those values. RNIapIos
was null
and isStorekit2Avaiable()
returned false
. This is on the latest release. Also note this error happens on Android as well. Do you think this could be an issue with Expo Go or something? I'm not very familiar with native modules or how they interact with Expo
yeah, so for me RNIapIos is defined, so it never checks isStorekit2Avaiable()
. i do think its likely that this is somehow related to Expo, however i have never used Expo so i dont know really what it would be. but it kind of seems like the native module has maybe not been built in
If you are using expo, take a look at: https://stackoverflow.com/a/73159706/570612
Is there any way to get around the error if you are using expo and don't want to build the project every-time?
Just so everyone is aware, I ended up switching to RevenueCat and now use the react-native-purchases
library. It is true that I have to build my app every time I want to test a change, which definitely is annoying.
@anishamalde I usually have to comment out any code before I test locally on both libraries. It won't work with Expo Go. At least the code is pretty straight forward once you have everything setup
@LorienHW @domuen @andresesfm i used react-native-iap -12.7.2 and i got similar error and got RNIapIos is null and isStorekit2Availabel() is false ...what is the solutions ? please help Sir...
Could be a problem with pod install?
@iasreact1 did you fill up the Agreements, Tax, and Banking section? It might be the problem. Remember that it takes till 24hs to be accepted.
If you are using expo, take a look at: https://stackoverflow.com/a/73159706/570612
yup, "expo go" won't work. expo development (native) build is required. thanks @andresesfm
question: is there a way to handle this error somehow so we can keep using expo go? current solution: grind
import Constants from 'expo-constants';
const isExpoGo = Constants.appOwnership === 'expo';
...
// App.js
export default isExpoGo ? App : withIAPContext(App);
...
// Somefile.js
if (!isExpoGo) {
const { connected, availablePurchases, getAvailablePurchases } = useIAP();
...
is there better way to handle this, maybe not to throw that error out if expo go is detected?
Could be a problem with pod install?
Yes, in my case, I just re-run 'pod install' and make sure the output contains "Installing RNIap", and the error is gone.
SOLVED
i added this in my initConnection : RNIap.purchaseUpdatedListener(purchase => { RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken); });
fixed when i add a condition :
if (Platform.OS === 'android') { RNIap.purchaseUpdatedListener(purchase => { RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken); }); }
I'm using an iOS emulator with iPhone 14 and iOS 17.5 but still encountering the E_IAP_NOT_AVAILABLE error.
I am building a mobile app (React Native) that requires subscriptions to use. I will be using Apple/Google pay on the respective platforms. I would like to request subscriptions with the
react-native-iap
library for React NativeI get the error "E_IAP_NOT_AVAILABLE" when calling the initConnection method from the react-native-iap library. I get this on both iOS and Android
My setup:
expo@46
react@18
react-native@0.69.6
react-native-iap@12.3.2
I have tried downgrading react-native-iap to versions
8.0.1
and7.0.3
(and reinstalling modules) with the same result.I can't seem to find any questions similar to this issue. Any ideas would be appreciated