Hi there. Can someone help me to set IAP for android? I’m getting crash while getting products information.
if (InAppPurchases::getInstance()->isInAppPurchasesSupported())
{
StringArray identifiers;
identifiers.add ("MyCoolProduct");
InAppPurchases::getInstance()->getProductsInformation(identifiers);
}
I see that GetProductsInformationJob is running fine and callback is called, but suddenly got crash while deleting one of jstring references in this line
I’ve just started to learn how things work in Android-Juce bridge. So probably I don’t know something significant about jstring object lifetime. I’ve tried to declare global const StringArray identifiers = {"MyCoolProduct"} but without luck
Well, the problem is still confusing me. The crash appears when GetProductsInformationJob object is destroyed inside Juce IAP classes. Please someone can confirm that IAP working well on Android?
Ok the problem is in the lifetime of LocalRef<jstring> packageNameToUse. LocalRef created by getPackageName() and passed to new job here (juce_android_InAppPurchases.cpp, line 120) threadPool->addJob (new GetProductsInformationJob (*this, getPackageName(), productIdentifiers, callback), true);
is deleted before the job finished of course. So SIGABRT appears.
E.g. this doesn’t crash: static auto packageName = getPackageName(); threadPool->addJob (new GetProductsInformationJob (*this, packageName, productIdentifiers, callback), true);
I believe there is normal solution: like using GlobalRef. Can anyone help me to figure it out? thanks