I use auto renewal subscription with react-native-iap in my app I need to check user has subscription on phone or not, for do this I use getAvailablePurchases() like this
import * as RNIap from 'react-native-iap';
const init = await RNIap.initConnection();
if (init) {
await RNIap.getAvailablePurchases()
.then((resp) => {
const sortedAvailablePurchases = resp.sort(
(a, b) => b.transactionDate - a.transactionDate,
);
const latestAvailableReceipt = sortedAvailablePurchases[0].transactionReceipt;
RNIap.endConnection();
return API({
method: 'POST',
url: '/subscription/check-receipt',
data: {
latestAvailableReceipt,
},
});
})
.catch((err) => {
RNIap.endConnection();
});
}
When I try to do this on my test device with sandbox, it works, but if I try to do this in the store build, I get the response - empty array
P.S I draw up subscription and then start testing