diff --git a/.env.example b/.env.example index 8d03180a8..08e72816e 100644 --- a/.env.example +++ b/.env.example @@ -116,6 +116,10 @@ SLACK_CLIENT_SECRET= ### Change this env variable only if you are using a custom build mobile app ## Mobile app env variables IOS_APP_ID=6C953F3RX2.com.chatwoot.app +ANDROID_BUNDLE_ID=com.chatwoot.app + +# https://developers.google.com/android/guides/client-auth (use keytool to print the fingerprint in the first section) +ANDROID_SHA256_CERT_FINGERPRINT=AC:73:8E:DE:EB:56:EA:CC:10:87:02:A7:65:37:7B:38:D4:5D:D4:53:F8:3B:FB:D3:C6:28:64:1D:AA:08:1E:D8 ### Smart App Banner diff --git a/app/controllers/android_app_controller.rb b/app/controllers/android_app_controller.rb new file mode 100644 index 000000000..c403d7756 --- /dev/null +++ b/app/controllers/android_app_controller.rb @@ -0,0 +1,5 @@ +class AndroidAppController < ApplicationController + def assetlinks + render layout: false + end +end diff --git a/app/views/android_app/assetlinks.json.erb b/app/views/android_app/assetlinks.json.erb new file mode 100644 index 000000000..575ca3b56 --- /dev/null +++ b/app/views/android_app/assetlinks.json.erb @@ -0,0 +1,12 @@ +[ + { + "relation": ["delegate_permission/common.handle_all_urls"], + "target": { + "namespace": "android_app", + "package_name": "<%= ENV['ANDROID_BUNDLE_ID'] %>", + "sha256_cert_fingerprints": [ + "<%= ENV['ANDROID_SHA256_CERT_FINGERPRINT'] %>" + ] + } + } +] \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 499588e42..667346c02 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -232,6 +232,7 @@ Rails.application.routes.draw do # ---------------------------------------------------------------------- # Routes for external service verifications get 'apple-app-site-association' => 'apple_app#site_association' + get '.well-known/assetlinks.json' => 'android_app#assetlinks' # ---------------------------------------------------------------------- # Internal Monitoring Routes diff --git a/spec/controllers/android_assetlinks_spec.rb b/spec/controllers/android_assetlinks_spec.rb new file mode 100644 index 000000000..a44ef111a --- /dev/null +++ b/spec/controllers/android_assetlinks_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +describe '.well-known/assetlinks.json', type: :request do + describe 'GET /.well-known/assetlinks.json' do + it 'successfully retrieves assetlinks.json file' do + get '/.well-known/assetlinks.json' + expect(response).to have_http_status(:success) + end + end +end