Question

Fetching the local subscription status with the Unity SDK

  • 23 August 2022
  • 5 replies
  • 60 views

Badge +1

We would like to display something to the user before swapping the subscription to a different user ID. That would mean knowing, when possible, the subscription status of the AppleID or Google Play account.

Is there a way to fetch the local subscription status with the SDK? Of course that information could be incomplete on iOS without a user-approved Restore, but it would still cover a large enough number of cases to help with the customer support.


5 replies

Userlevel 4
Badge +8

Hey @Gabriel_Ulu , 

 

You can use the `SyncPurchases` method for that (https://github.com/RevenueCat/purchases-unity/blob/main/RevenueCat/Scripts/Purchases.cs#L588)

 

This will do a restore without refreshing the receipt, so like you said, it might be incomplete, but will still cover a large number of cases. 

 

If you call `LogIn` afterwards in your app, you should call `SyncPurchases` again after `LogIn` so that if a purchase got transferred to an anonymous ID, it gets transferred back. More information about that here https://docs.revenuecat.com/docs/user-ids

 

 

Badge +1

Hi @Andy,

My understanding is that SyncPurchases would still result in the local subscription being linked to the current Revenue Cat user.

We'd like to know before such a transfer, that we have a local active subscription to actually transfer. We’d like to get the device’s subscription status, without linking it to the current user.

 

This is because our app is cross platform and transferring the iOS subscription from User A to User B would mean another (Android or iOS) device using User A credentials would lose access to the game. What we want to do is give the user some understanding about what is going on with his subscription to limit customer support. 

Userlevel 4
Badge +8

Ohh I see. 🤔

That’s a use case that I don’t think we cover. We don’t currently expose any methods that introspect the receipts / tokens _without_ posting them to the backend. 

 

You could check whether the user has an active subscription in RevenueCat, and if they don’t, warn them that if they have an active subscription through App Store / Google Play and they log in, it’ll get transferred out. 

Then you can provide a button with a link to: 

https://apps.apple.com/account/subscriptions on iOS

https://play.google.com/store/account/subscriptions on Android with Google Play

 

So that they can check their subscription status themselves. 

Sorry we hadn’t thought of this case yet 😅

Badge +1

Another issue of not being able to fetch the local subscription status is that we're not able to manage the user logging out of our account system (or uninstalling/reinstalling), creating a new account, getting to the shop and purchasing a second different subscription (we offer a monthly and a yearly subscription).

On Android, this leads to the user paying for 2 subscriptions as the Revenue Cat's SDK does not seem to handle the Upgrade/Downgrade of Android subscriptions.

If he purchases the same subscription he had before, we get the PRODUCT_ALREADY_PURCHASED error (6) and silently sync the user's purchase to his account, but we cannot do anything about the user selecting the other subscription product.

Userlevel 4
Badge +8

@Gabriel_Ulu 

Our SDK does provide the ability to handle upgrades and downgrades by passing in the old product information (see https://github.com/RevenueCat/purchases-unity/blob/main/RevenueCat/Scripts/Purchases.cs#L333). 

 

However, the only way for it to work is to go through syncPurchases first, which will transfer the purchase, like you pointed out previously. 

 

Reply