Cross-platform In-app Subscription Management Guide: How to Manage Subscribers’ Access Across iOS, Android, and Web

Suren avatar
Suren

Managing subscribers’ access across iOS, Android, and the web can be quite challenging. To offer a seamless user experience independently of the platform, you have to implement a pretty complex logic: user authentication, real-time subscription updates, and the most crucial part — building the single solution connecting all the platforms.

Let’s imagine you want to monetize a streaming app with in-app subscriptions on iOS and Android platforms. And you also want to be able to provide premium service to your mobile subscribers on the web app or Smart TV.

The main pain points you have to solve are:

  • Create the authentication system
  • Handle platform-based subscription flow
  • Retrieve subscribers data on every platform (iOS/Android/Web) to manage the access

We’re going to have a look at the aforementioned cross-platform subscription management case especially these steps of the process:

  • A user creates a profile using an iOS or Android app
  • Then they purchase an in-app subscription
  • Finally, log on to different platforms (either iOS or Android or Web) and receive premium features based on their original subscription

Preparation

We’ll use the Qonversion platform and SDK to handle purchases. You need to have Qonversion products set and linked to App Store or Google Play Store to be able to test the described cross-platform access management using this post. You can check the guide on setting the in-app products with Qonversion here.

The screenshots below demonstrate in-app products and permissions set up in Qonversion. Permission shows you which access will be granted once a product is purchased. 

Products
Permissions

All examples below are based on this product purchase.  

Authenticating a User

We’re using the Firebase authorization in this example. You can have any authentication backend according to your requirements and preferences. What matters is that you need to have the user ID for an authenticated user regardless of the platform they use to log in. Google’s Firebase provides a flexible, out-of-the-box authentication service that’s easy to integrate into your app.

You can use it to create new user profiles with email and password or even social authorization with platforms like Facebook or Twitter.

Firebase authentification

Send Authenticated User ID to Qonversion

Once you have the authentication process in place, you can send authenticated User ID to Qonversion using the identify method: Qonversion.identify("your_custom_user_id") (check the code for other platforms here).

This will allow Qonversion to attribute the following purchases of that user and manage cross-platform user access.

Handle User Subscription

Offer your user a subscription and handle purchases. You can use Qonversion SDK methods to get the details of the available in-app products, handle purchases, and check if a user is entitled to use premium features based on his subscription status. 

You can check the details on making purchases with a subscription here

In the case of the Swift iOS app, you can use Qonversion’s purchase product method when users clicks on the purchase button:

Qonversion.purchaseProduct(product) { (permissions, error, isCancelled) in
  
  if let premium: Qonversion.Permission = permissions["premium"], premium.isActive {
    // Flow for success state
  }
}

Apple shows a system notification to a user to confirm a purchase: 

If the user confirms the purchase and it’s successful, the Qonversion.purchaseProduct() method will return a permissions object that indicates the user has an active subscription. You can read more on permissions objects here.

Grant premium access to authenticated user on another mobile platform (Android)

Let’s open up the Android app and choose the same authentication account that we’ve used for iOS. On the main screen of your app, you can see that the purchase is completed; although, we didn’t purchase anything on this device yet. This is a permission from the purchase that we have done from iOS device.

Let’s have a look at how to unlock premium access to that user on a different mobile platform. We’ve assumed that the original purchase was made on iOS. When this user logs in on Android, call identify method.

Qonversion.identify("your_custom_user_id");

Qonversion will get the data for that user and will be able to match it to an existing user with a subscription on iOS. All you need to do next is use checkPermissions method on the Android app. The permission object returned from this method has isActive field. This field is equal to True in case Qonversion has the data on his active subscription on iOS. As you’ll see in the next section, you can get the data for this user through API to manage access from your database or on the web app.

Grant premium access on web application 

Let’s move to the web. The first step is to create a user on the web. To do this, use API:

https://api.qonversion.io/v3/users/{id}

Then, log in to your application with the same account that we used in the previous steps.

As we did previously for mobile platforms, we need to call an identity for your web application user. Use the following API:

https://api.qonversion.io/v3/identities/{identity_id}

In response, you’ll get an identity user id that you must use in the following steps. Learn more in the documentation.

Now, let’s request an entitlement object that indicates if the user has an active subscription and is entitled to access premium features or not.

To request the entitlement, you need to use your identity user id that we created and used in the previous steps inthe following way:

https://api.qonversion.io/v3/users/{user_id}/entitlements

The API response contains the entitlements objects. If the user has active subscriptions, the field active equals true.

If a user has not subscribed to any in-app products, the entitlements array is empty. If a user subscribed to a product but the subscription expired, the entitlements array contains entitlement objects and the field active of the entitlement object equals false.

{
  "data": [
    {
      "active": false,
      "expires": 1656463609,
      "id": "plus",
      "product": {
        "product_id": "main",
        "subscription": {
          "current_period_type": "normal",
          "renew_state": "canceled"
        }
      },
      "started": 1652438020
    },
    {
      "active": true,
      "expires": 0,
      "id": "Premium Movies",
      "product": {
        "product_id": "in_app"
      },
      "started": 1645602180
    },
    {
      "active": false,
      "expires": 1655687007,
      "id": "standart",
      "product": {
        "product_id": "subs_plus_trial",
        "subscription": {
          "current_period_type": "normal",
          "renew_state": "canceled"
        }
      },
      "started": 1655472799
    }
  ]
}

You can check the detailed documentation for the API methods here.

In Conclusion

Managing subscription statuses and purchases across multiple platforms with Qonversion is quick and simple. Qonversion stores the data on subscriptions and makes it available to you on mobile platforms with its SDKs and through API for the web users. This saves a lot of engineering time. You don’t need to worry about building the subscriptions back-end infrastructure and can focus on your product instead.

If you still have any questions on cross-platform subscriptions implementation, feel free to reach out us via the #developers chat in our Subscription Apps Slack Community. We would love to hear from you!