How do i check on both platforms that a subscription is active? I read in one forum post that ProcessPurchase event will automatically gets called next time you run the app on iOS with all the product info, (assuming not on android)
So what;d be the right way to approach this? What i want to do is everytime user logins the app i check if user has a subscription active (this is where i need help), and then also verify it on backend (assuming ill always have a receipt of purchased product) and then toggle premium features.
Yeah, if you follow that code, the “dict” variable remains null. So you can avoid the Apple mention altogether on Google/Android. I would suggest the package Samples first, then the Sample IAP Project (they are newer).
A “complete demo” of course could never exist, someone will always want another feature. But we do have this updated Sample IAP Project, and the great Samples that are listed in Package Manager for In App Purchasing https://discussions.unity.com/t/700293/4
Sorry to necro, but i can’t seem to get SubscriptionInfo working, i even tried this,
SubscriptionInfo info = new SubscriptionInfo("mysub");
Result result = info.isSubscribed();
print(result);
on the IAP purchasing example project you made on the other thread, it always comes back true, even when i tried deleting the project and running it without subscribing. Am i doing it wrong? Am i supposed to run through a list of the products or something? Even in my project, the result is always returning true even when the subscription has not been purchased…
You don’t want to use the ```SubscriptionInfo(string productId)
You should go through the SubscriptionManager to obtain the SubscriptionInfo.
He's an extract of it from our sample 02 BuyingSubscription:
```csharp
bool IsSubscribedTo(Product subscription)
{
// If the product doesn't have a receipt, then it wasn't purchased and the user is therefore not subscribed.
if (subscription.receipt == null)
{
return false;
}
//The intro_json parameter is optional and is only used for the App Store to get introductory information.
var subscriptionManager = new SubscriptionManager(subscription, null);
// The SubscriptionInfo contains all of the information about the subscription.
// Find out more: https://docs.unity3d.com/Packages/com.unity.purchasing@3.1/manual/UnityIAPSubscriptionProducts.html
var info = subscriptionManager.getSubscriptionInfo();
return info.isSubscribed() == Result.True;
}