LinkFive - Successful Subscriptions

Get All Active Subscriptions

Get All Active Subscriptions

Please read How to initialize the plugin before you start with this part.

Usually you would want to know, if the user already purchased a subscription after app start. In this case the flutter plugin has a function to get all active subscriptions.

If the user has no active subscriptions, you might want to offer a subscription to the user by fetching all available subscriptions.

Receive all Active Subscriptions / Plans

LinkFive mainly works with streams. You can listen to a stream using the LinkFivePurchases static object. To get all active subscriptions, you need to get the stream by calling .activeProducts and listen on the Stream.

// somewhere in your code
void _activeProductsUpdate(LinkFiveActiveProducts data) {
// save the data, or parse it.
activeProducts = data;
// in a provider, you might want to notify all listeners

The stream will pass all verified and active subscriptions to your app. We also check if the receipt is valid by calling the Apple or Google APIs.

Cancel your stream when done

In your dispose method, please don't forget to cancel the stream by calling cancel.

Looking at the first example above, you would want to save the result of the stream and call cancel on dispose.

_stream = LinkFivePurchases
void dispose() async {
await _stream.cancel();

Active Subscriptions using the Provider Plugin

No additional work needed. You will find all active subscriptions in your provider.

// Access all active subscriptions after consuming LinkFiveProvider

Next: Show your Subscription Offer