diff --git a/content/docs/images/android-app-links-debug.png b/content/docs/images/android-app-links-debug.png new file mode 100644 index 00000000..1d534a7b Binary files /dev/null and b/content/docs/images/android-app-links-debug.png differ diff --git a/content/docs/images/android-app-links-fingerprints.png b/content/docs/images/android-app-links-fingerprints.png new file mode 100644 index 00000000..633ac049 Binary files /dev/null and b/content/docs/images/android-app-links-fingerprints.png differ diff --git a/content/shared/in-app-paywall-previews.mdx b/content/shared/in-app-paywall-previews.mdx index 8e533cf0..f14995d2 100644 --- a/content/shared/in-app-paywall-previews.mdx +++ b/content/shared/in-app-paywall-previews.mdx @@ -361,6 +361,121 @@ class _MyAppState extends State { } ``` ::: + +:::android +### Handling App Links + +## Adding app links + +Android App links enable seamless integration between the Web checkout and your app, +enabling users to redeem the purchase automatically. + +To allow Android app links to open your app, you will need to follow these steps: + + +## 1. Add your app's fingerprint and schema to Stripe settings + +To verify that the request to open the app is legitimate, Android requires your app's keystore SHA256 fingerprint, with at least one for your development keystore and one for your release keystore. You can obtain these fingerprints in the following way: + +#### Development fingerprints + +If you're using Android studio or have Android components installed, you can obtain your debug key by running the following command in your terminal: + +`keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android` + +And then copying the outputted SHA256 fingerprint. + + +#### Release fingerprints + +To obtain the release fingerprints, you'll need your own keystore file (the one you use to sign the final application package before publishing). + +You can do this by running the following command in your terminal: + +`keytool -list -v -keystore -alias ` + +And then copying the outputted SHA256 fingerprint. + + +#### Adding the fingerprints to the project + +To add the fingerprints to Superwall, open the Settings tab of your Superwall Stripe application. +Under the `Android Configuration` title, you should see three fields: + +- Package schema - this allows us to know which schema your app uses to open and parse deep links +- Package name - your app's package name, i.e. `com.mydomain.myapp` +- App fingerprints - One or more of your app's fingerprints, comma separated + + +![](/images/android-app-links-fingerprints.png) + + +Once added, click the `Update Configuration` button which will ensure the application asset links are properly generated for Google to verify. + + +### 2. Add the schema to your app's Android Manifest + +For this, you'll need to copy the domain from your Superwall Stripe settings. +Then, open your `AndroidManifest.xml` and inside the `` tag declaring your deep link handling activity, add the following, replacing the domain with the one from the settings: + +```xml + + + + + + + + + +``` + +### 3. Handle incoming deep links using Superwall SDK + +In the same activity as in step #2, you'll need to pass deeplinks along to Superwall SDK. +You can do this by overriding your Activity's `onCreate` and `onNewIntent` methods and passing along the intent data to Superwall using `Superwall.handleDeepLinks()` method. The method returns a `kotlin.Result` indicating if the deep link will be handled by Superwall SDK. + +```kotlin +override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + // your onCreate code + intent?.data?.let { uri -> + Superwall.handleDeepLink(uri) + } +} + +override fun onNewIntent(intent: Intent, caller: ComponentCaller) { + super.onNewIntent(intent, caller) + // ... Your onNewIntent code + intent?.data?.let { uri -> + Superwall.handleDeepLink(uri) + } +} +``` + + +### 4. Handling links while testing + +If you are running your app using Android Studio, you need to be aware that it won't automatically allow verified links to be opened using the app, but you will need to enable it in settings yourself. This is not the case when installing from Play Store, and all the links will be handled automatically. + +To do that, once you install the app on your device, open: +`Settings > Apps > Your Application Name > Open By Default` + +Under there, the `Open supported links` should be enabled. +Tap `Add Links` button and selected the available links. + +![](/images/android-app-links-debug.png) + + +### Testing & more details + +For details regarding testing and setup, you can refer to [Android's guide for verifying app links](https://developer.android.com/training/app-links/verify-android-applinks). +Note - Superwall generates the assetlinks.json for you. To check the file, you can use the subdomain from your Superwall stripe configuation: + +`https://my-app.superwall.app/.well-known/assetlinks.json` +:::android + :::expo You can use the Superwall SDK to handle the deeplink with `SuperwallExpoModule.handleDeepLink(url)`. Here, we have code to ensure that the deep link opens a preview when the app is booted from the deep link, and when it's already in the foreground running: