From 03b8cdea8d7115bd28057bf503023219f6d78bf3 Mon Sep 17 00:00:00 2001 From: IanRDavies Date: Thu, 21 Apr 2022 14:57:36 +0100 Subject: [PATCH] android: support app links via simplex.chat (#545) * update manifest * autoverify domain * add path prefix to intent filter * support contact links * add android app readme * only allow a single simplex task at a time to avoid opening simplex 'on top' of app with link --- apps/android/app/src/main/AndroidManifest.xml | 57 ++++++++++++------- .../java/chat/simplex/app/MainActivity.kt | 6 +- apps/android/readme.md | 25 ++++++++ 3 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 apps/android/readme.md diff --git a/apps/android/app/src/main/AndroidManifest.xml b/apps/android/app/src/main/AndroidManifest.xml index 17c4303b2..b7e2e930a 100644 --- a/apps/android/app/src/main/AndroidManifest.xml +++ b/apps/android/app/src/main/AndroidManifest.xml @@ -1,33 +1,35 @@ + package="chat.simplex.app"> + - - - - + + + + + android:name="SimplexApp" + android:allowBackup="true" + android:icon="@mipmap/icon" + android:label="@string/app_name" + android:supportsRtl="true" + android:theme="@style/Theme.SimpleX"> + android:name=".MainActivity" + android:launchMode="singleTask" + android:exported="true" + android:label="@string/app_name" + android:windowSoftInputMode="adjustResize" + android:theme="@style/Theme.SimpleX"> @@ -36,10 +38,24 @@ + + + + + + + + + + + + + + + android:resource="@xml/file_paths" /> @@ -57,8 +73,7 @@ android:name=".SimplexService" android:enabled="true" android:exported="false" - android:stopWithTask="false"> - + android:stopWithTask="false"> - + @@ -74,6 +89,6 @@ + android:exported="false" /> diff --git a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt index 1b08da469..09160bd55 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt @@ -39,7 +39,6 @@ class MainActivity: ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // testJson() - processIntent(intent, vm.chatModel) setContent { SimpleXTheme { Surface( @@ -54,6 +53,11 @@ class MainActivity: ComponentActivity() { schedulePeriodicServiceRestartWorker() } + override fun onNewIntent(intent: Intent?) { + super.onNewIntent(intent) + processIntent(intent, vm.chatModel) + } + private fun schedulePeriodicServiceRestartWorker() { val workerVersion = chatController.getAutoRestartWorkerVersion() val workPolicy = if (workerVersion == SimplexService.SERVICE_START_WORKER_VERSION) { diff --git a/apps/android/readme.md b/apps/android/readme.md new file mode 100644 index 000000000..7822847e5 --- /dev/null +++ b/apps/android/readme.md @@ -0,0 +1,25 @@ +# Android App Development + +This readme is currently a stub and as such is in development. + +Ultimately, this readme will act as a guide to contributing to the develop of the SimpleX android app. + + +## Gotchas + +#### SHA Signature for verification for app links/deep links + +In order for the SimpleX app to be automatically adopted for opening links from https://simplex.chat the SHA certificate fingerprint for the App installed on the phone must be in the hosted [assetlinks.json](https://simplex.chat/.well-known/assetlinks.json) file on simplex.chat. + +The accepted fingerprints are in the `sha256_cert_fingerprints` list. + +To find your SHA certificate fingerprint perform the following steps. + +1. Build and install your development version of the app as usual +2. From the terminal in Android studio run `adb shell pm get-app-links chat.simplex.app` +3. Copy the signature listed in `signatures` in the result +4. Add your signature to [assetlinks.json](https://github.com/simplex-chat/website/blob/master/.well-known/assetlinks.json) in the [website repo](https://github.com/simplex-chat/website) and make a PR. On approval, wait a few minutes for the changes to propagate to the public website and then you should be able to verify SimpleX. + +More information is available [here](https://developer.android.com/training/app-links/verify-site-associations#manual-verification). If there is no response when running the `pm get-app-links` command, the intents in `AndroidManifest.xml` are likely misspecified. A verification attempt can be triggered using `adb shell pm verify-app-links --re-verify chat.simplex.app`. + +Note that this is not an issue for the app store build of the app as this is signed with our app store credentials and thus there is a stable signature over users. Developers do not have general access to these credentials for development and testing.