5

I am implementing deep linking to my android app and it works only when clicking on a link with the desired url such as https://mydomain.co.il only outside browsers like in whatsapp etc. I know that for making app links work from browser, the website needs to have assetlinks.json file located at https://mydomain.co.il/.well-known/assetlinks.json in order to verify that I am the owner of both the domain and the app.

So I do have the assetlinks.json file ready but does anyone know how can I put the file in that specific location (https://mydomain.co.il/.well-known/assetlinks.json) on my website when using Wix as the platform ?

Thanks in advance

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
Yarin Shitrit
  • 297
  • 4
  • 16

1 Answers1

2

I struggled to find a straightforward way to host the Android Digital Asset Links file on Wix. Found bits and pieces of help on the net. Tested my code and it seems to work.

Here it goes:

  1. Android needs a Digital Asset Links file hosted on the website of an app to verify ownership. The link required is: https://www.yoursite.com/.well-known/assetlinks.json
  2. Since hosting this file at that location was not a plausible solution on Wix (at least to me at the time of this post), we'll need to add a JS file which can spit out the same JSON data and then redirect the URL Google expects to our new link.
  3. Go to Dev Mode -> Enable Developer Mode and switch on the developer mode
  4. In the new left pane, go to {} (Public & Backend)
  5. Next to Backend, click on +, and create a new Javascript file with the name http-functions.js
  6. Add this code:
// Import the Wix http functions API 
import {ok, notFound, serverError} from 'wix-http-functions';  

// Set the assetlinks variable (between the single backticks) with the content of your assetlinks.json file 

let assetlinks = `[{
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target" : { "namespace": "android_app", "package_name": "<Your app package>",
                    "sha256_cert_fingerprints": ["<Your app's SHA256>"] }
}]`  

// Define http get function for your trust.txt file 

export function get_assetlinks(request) {     
    let options = {         
        "headers": {             
            "Content-Type": "text/plain"
        },
        
        "body": assetlinks     
    };     
    return ok(options); 
} 
  1. Publish your site
  2. Test if the JSON is displayed by calling: www.yoursite.com/_functions/assetlinks

Hoping that things are great so far, we'll proceed to the last and final step - URL redirection

  1. Go to site Settings > Marketing & SEO > SEO Tools > URL Redirect Manager
  2. Click on New Redirect and enter for: Old URL: /.well-known/assetlinks.json New URL: /_functions/assetlinks
  3. Test out the link www.yoursite.com/.well-known/assetlinks.json

Hope this helps someone! Better late than never.

deetho
  • 73
  • 7
  • there's one typo: in step 5, the file name should be 'http-functions.js' so it has hyphen, not underbar. Then it works! Thanks! – Brian Hong Jan 14 '23 at 18:24
  • Well, I got an error: basically saying 'redirection is not allowed'. – Brian Hong Jan 14 '23 at 19:18
  • @BrianHong well noted. Corrected the typo. – deetho Jan 16 '23 at 18:17
  • @BrianHong were you able to figure this out? – Sahil Khurana Jun 16 '23 at 12:18
  • I got it running using above. But according to this link Google don't allows any 301 or 302 redirects. https://developer.android.com/training/app-links/verify-android-applinks#publish-json. So i contacted Wix support for any direct links and they simply excused – Bilal Ahmed Aug 07 '23 at 12:21