Deeplinks guide
This article explains what deeplinks are, why they matter, and how to use them with examples.
What are deeplinks?
A deeplink is a URL that opens not the app’s main screen, but a specific section or function inside it. For example, instead of opening the store home page, a link can take the user straight to a product card or the cart.
Deeplink example::
myapp://profile/123 — opens the profile of the user with ID 123.
Why use deeplinks
-
Better user experience Deeplinks reduce the number of steps to complete an action. Users land on the exact screen they need, making interactions faster and easier.
-
Marketing campaigns In campaigns, deeplinks drive users to specific promos, products, or features. Tapping a link opens that product’s card in the app, bypassing search and navigation.
Push notification with an attached deeplink: “Get 20% off your favorite brand! Tap to order” — takes the user directly to the brand page.
- Integration with other services Deeplinks simplify interactions with external apps such as payment services or partner programs.
Payment via a third-party app (e.g., SBP or SberPay) with an automatic return to the confirmation screen in your app.
How deeplinks work
-
Deeplink structure Deeplinks follow a clear format that points to a specific screen or action. Examples:
myapp://profile/123— opens a user profile.myapp://order/987— opens order #987.myapp://payment?amount=100— opens the payment screen with a prefilled amount.
-
Handling deeplinks in the app Your app must be configured to recognize such URLs and perform the relevant actions. This is done:
- via Android intents (intent filters),
- by configuring a custom URL scheme or Android App Links.
-
Navigation and actions When a user taps a deeplink, Android launches your app and passes the link parameters. The app processes the request and routes the user to the target screen.
Why handle deeplinks in the Billing SDK
Deeplink handling is required for correct interaction with bank apps and payment systems (e.g., SBP, SberPay, Tinkoff Pay).
Key tasks covered by deeplinks in the Billing SDK:
- Automatic completion of payment After switching to a third-party app for payment (bank client or SBP service), a deeplink returns the user to your app to show the transaction status (success/failure).
The user confirms a purchase in their banking app. After payment, a deeplink returns them to the order confirmation screen in your app.
- Shorter payment path Deeplinks streamline payment by taking the user straight to the relevant screen in the external app, skipping extra steps.
A link like myapp://payment/redirect opens the banking app for confirmation, then the deeplink automatically returns the user to your app.
- Integration with popular payment services Deeplinks are especially important for SBP and services like SberPay or Tinkoff Pay, which operate together with bank apps. Thanks to the deeplink scheme, the user is automatically returned to your app.
The user selects Tinkoff Pay. The SDK creates a deeplink that takes them to the bank app to confirm. After completion, the user returns to your app to see the result.
How to handle deeplinks for Billing SDK payments
- Specify a
deeplinkSchemein yourAndroidManifest.xmlfor theActivityyou want to return to after payment in a third-party app. The SDK generates its own host for this scheme; you don’t need to specify it.
<activity
android:name=".YourBillingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="your_deeplink_scheme" />
</intent-filter>
</activity>
Replace your_deeplink_scheme with your scheme, e.g., ru.package.name.rustore.scheme.
- When creating the
RuStoreBillingClientFactory, pass the samedeeplinkSchemeyou specified inAndroidManifest.xml.
val billingClient: RuStoreBillingClient = RuStoreBillingClientFactory.create(
context = app,
consoleApplicationId = "111111",
deeplinkScheme = "your_deeplink_scheme",
// Optional parameters
themeProvider = null,
debugLogs = false,
externalPaymentLoggerFactory = null,
)
- To restore your app’s state when returning via a deeplink, add
android:launchMode="singleTask"to the targetActivityinAndroidManifest.xml(see below).
<activity
android:name=".YourBillingActivity"
android:launchMode="singleTask"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
- In the
Activitythat receives control after payment (the screen for which you configured thedeeplinkScheme), add the following code:
class YourBillingActivity: AppCompatActivity() {
// Previously created with RuStoreBillingClientFactory.create()
private val billingClient: RuStoreBillingClient = YourDependencyInjection.getBillingClient()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
billingClient.onNewIntent(intent)
}
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
billingClient.onNewIntent(intent)
}
}
Call billingClient.onNewIntent(intent) in both onCreate and onNewIntent when returning to the app after SBP payment—to display the completion sheet and finish the payment flow.
Additional information
The following reference describes the structure of URI schemes and allowed characters: https://datatracker.ietf.org/doc/html/rfc3986#section-3.1