I am looking to be able to show unlocked features in a web based version of my app. If I make it so users can subscribe in either the iPhone or Android store but still access un-locked content on the web or desktop versions?
Can I check if user is subscribed on flutter web app?

Hey
If your users have the same user ID, then the subscriptions will be shared across multiple platforms and all you will need to do is call getCustomerInfo() to access if they have a subscription or not.
More information on checking if they have an active subscription can be found here: https://www.revenuecat.com/docs/customer-info#get-user-information

So not sure web and PC work with flutter?

Future<bool> _getSubscriptionStatusWeb(User user) async {
bool hasActiveSubscription = false;
try {
Uri uri = Uri.https('api.revenuecat.com', '/v1/subscribers/${user.id!}');
await http.get(uri, headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $revenueCatApiKey',
}).then((response) {
if (response.statusCode == 200) {
Map<String, dynamic> customerInfo = json.decode(response.body);
Map<String, dynamic> entitlements =
customerInfo['subscriber']['entitlements'];
if (entitlements.isNotEmpty) {
List<DateTime?> expiryDates = entitlements.values
.map((entitlement) =>
DateTime.tryParse(entitlement['expires_date']))
.toList();
hasActiveSubscription = expiryDates.firstWhereOrNull(
(element) => element!.isAfter(DateTime.now())) !=
null;
}
}
});
} catch (e) {
debugPrint("Unable to retrieve subscriber status from Revenuecat");
}
return hasActiveSubscription;
}



yup I was just tired… lol
I will give this a try, thanks!

Undefined name 'http'.
and
The method 'firstWhereOrNull' isn't defined for the type 'List'.
Try correcting the name to the name of an existing method, or defining a method named 'firstWhereOrNull'.
Assuming $revenueCatApiKey I just replace with my api key? And User user I can change to a string to my user ids?

I'm sorry, but may I suggest you rethink your approach to dealing with this? It appears you want to go the way of least resistance and have someone work it out for you, rather than learning how to build a solution for yourself. It took me about 5 seconds to find the answers to those questions on http and firstWhereOrNull. With respect to the api key I would suggest to review the http package and the fundamental principles of a web api.
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.