react-native-android-appcheck
v1.0.0
Published
Yet another react-native package
Downloads
5
Readme
react-native-android-appcheck
Tool to check for install status of apps on Android
Why?
Linking.canOpenURL
works well for "Deep Links" with custom schema (e.g. exampleapp://
), however it is less useful when an app only implements "App Links" with domain verification (i.e. android:autoVerify="true"
). See this Android documentation page: https://developer.android.com/training/app-links/verify-site-associations#the-difference
Since a browser is capable of opening general HTTPS URLs, Linking.canOpenURL('https://applink.exampleapp.com')
will always return true, whether or not "exampleapp" is installed.
One real-world example of this is Apple Music on Android. On iOS, the music://
schema can be queried for, but on Android (>= 6.0), only an "app link" is available. In this case, custom schemas are present, but the autoVerify
attribute 'locks' the intent-filter to the https domains. Android versions lower than 6.0 are probably still able to query for the custom schemes (autoVerify implemented in 6.0/Marshmallow).
Status
- Android:
- Testing functionality
- iOS:
- No support planned
- react-native:
- supported versions ">= 0.60.5"
Installation
0. Setup Swift and Kotlin
Modify
android/build.gradle
:buildscript { ext { ... + kotlinVersion = "1.3.50" } ... dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") ...
1. Install latest version from npm
$ npm i react-native-android-appcheck -S
Demo
Android | iOS :---------------------------------------------:|:---------------------------------------------: ??? | ???
Example
import checkPackage from 'react-native-android-appcheck'
(async function() {
const isInstalled = await checkPackage('com.chat.fakeapp');
console.log(`App is installed: ${isInstalled}`);
}());