Control Google Play messages in Android SDK

Google Play sometimes needs to show your users a message about their subscription — for example, that a subscription payment was declined and the payment method needs an update. Google Play shows these messages on top of your app, only when the app requests them.

By default, the Adapty SDK requests Google Play messages every time an Activity of your app starts. The message then appears over whatever that Activity displays, including a flow, an onboarding, or a checkout. To choose the moment yourself, switch the SDK to manual message handling, and call showStoreMessages when a message won’t interrupt the user.

Google Play decides whether a message applies to the user, so a request doesn’t always show a message. If the user fixes their payment method from the message, the SDK syncs the user’s purchases with Adapty, and your profile listener receives the updated access level.

Warning

In manual mode, the SDK never requests Google Play messages on its own. If your app never calls showStoreMessages, users with a declined payment don’t see the notice in your app.

Before you start

You need Adapty Android SDK 4.3.0 or later. Earlier versions don’t request Google Play messages.

Enable manual handling

To request Google Play messages only when your app calls showStoreMessages, set withStoreMessagesHandling to MANUAL when you activate the SDK:

Show messages

When your app reaches a point where a Google Play message won’t interrupt the user — for example, after the user closes a flow or finishes onboarding — call showStoreMessages with the Activity that displays the message:

The method returns no result. The SDK doesn’t request a message in these cases:

  • The SDK isn’t activated: Call showStoreMessages after Adapty.activate.
  • The Activity can’t display a message: The Activity is finishing or destroyed, or its window isn’t attached yet. Call the method from an Activity that the user sees.

In the default AUTO mode, you can also call showStoreMessages — for example, to request a message again on an Activity that is already running.