ucam-department-of-psychiatry / camcops

Cambridge Cognitive and Psychiatric Test Kit (CamCOPS)
Other
12 stars 8 forks source link

Android App Links broken #335

Open martinburchell opened 7 months ago

martinburchell commented 7 months ago

Up until now it has been possible to automatically launch CamCOPS with an "AppLink" starting with http://camcops.org/register. The fact that this was a broken link didn't matter; the app would treat the URL as special without it being passed to a browser.

Now it seems that Google have changed how App Links work and we are getting errors on the Play Store about broken links and unverified domains. I suspect that the App Links won't work at all now. This needs some investigation into how we are meant to do this now.

Workaround is for users to enter their registration details manually.

RudolfCardinal commented 7 months ago

The docs suggest that App Links are still a thing: https://developer.android.com/training/app-links. The only API levels mentioned there is 23 (which is the minimum we support). But there is perhaps a new verification system: https://developer.android.com/training/app-links/verify-android-applinks. That suggest that we need to host e.g. "https://camcops.org/.well-known/assetlinks.json". The challenge for that might be the HTTPS and the redirection involved to camcops.readthedocs.io. We could shift to using the readthedocs domain, I suppose.

martinburchell commented 7 months ago

It's possible also that we could use deep links instead where the scheme could be "camcops" instead of http. This is effectively what happens on iOS. The disadvantage of this is that email clients won't treat these as hyperlinks so they can't be followed. You can still copy and paste into a browser though.

martinburchell commented 4 months ago

It's possible also that we could use deep links instead where the scheme could be "camcops" instead of http. This is effectively what happens on iOS. The disadvantage of this is that email clients won't treat these as hyperlinks so they can't be followed. You can still copy and paste into a browser though.

Actually this is next to useless because browsers won't recognise non-http schemes even with copy and paste. The only way I could get this to work was using adb from a connected Ubuntu machine: ./adb shell am start -a android.intent.action.VIEW -d custom://example.org/register/?label=Hello org.example.urlhandler/.CustomActivity

Experiments at https://github.com/martinburchell/qt-android-url-handler

I think the only way forward would be use the HTTP scheme and host the necessary files at camcops.org. The advantage of this is that we should be able to direct users to the app store if the app isn't already installed. Alternatively seek another way to make registration easier such as scanning a QR code.

RudolfCardinal commented 4 months ago

OK. The slight concern I have about camcops.org is its nature as a redirection site. Currently, http://camcops.org/ redirects to http://camcops.readthedocs.io (it's a Network Solutions redirection domain) but https://camcops.org/ doesn't work. In general, even if that did, there might be some risks associated with a redirection, i.e. not all software might accept it (and it requires the software to accept the redirection and then the certificate associated with the second site name). Is there an option to go direct to the ReadTheDocs or GitHub site?

martinburchell commented 4 months ago

From https://developer.android.com/training/app-links/verify-android-applinks:

Declare the association between your website and your intent filters by hosting a Digital Asset Links JSON file at the following location:

https://domain.name/.well-known/assetlinks.json

We wouldn't be able to do that on GitHub or ReadTheDocs.

It wouldn't have to be camcops.org but we'd need a domain plus some hosting space and all of the costs that entails (or access to someone else's).

RudolfCardinal commented 4 months ago

Yes, fiddly. Currently the routing DNS service is just one I pay for personally. Could we use GitHub Pages?

martinburchell commented 4 months ago

Yes, fiddly. Currently the routing DNS service is just one I pay for personally. Could we use GitHub Pages?

* https://pages.github.com/ (a site for the University, and can have multiple project pages);

* then with some fiddling the ".well-known" folder can be hosted: https://github.com/orgs/community/discussions/22227

Ah, of course so it would be on a subdomain. I'll investigate.