humhub / app

18 stars 7 forks source link

Open URLs with App (Uni Links) #13

Closed luke- closed 1 year ago

luke- commented 1 year ago

It would be great it links to the active HumHub URL (e.g. via E-Mail) will be opened inside the app and not inside the standard browser.

> I don’t think it’s possible, that the App dynamically registers URL Prefixes.

I did some tests with Rocket.chat mobile app which allows you to write the domain of the Rocket instance.
I received a notification by email, and when I click on the link in the email for the first time it asks me if I want to open it in the Rocket app or in the Browser. Choosing the app opens the page correctly in the app.
So it should work for Humhub to!

https://community.humhub.com/comment/perma?id=43822

PrimozRatej commented 1 year ago

https://pub.dev/packages/uni_links

PrimozRatej commented 1 year ago

This can be accomplished with the following data definition for and redirect intent (for now impl. only for android but it's also possible for iOS): <data android:scheme="https" android:host="*.humhub.com" /> We are intercepting all redirects that follow the format: https://{something}.humhub.com/{anything}

PROBLEM:

@luke- , how would you suggest we proceed in this case?

luke- commented 1 year ago

@PrimozRatej Usually HumHub installations run under their own domain, e.g. https://social.example.com - can we somehow cover these cases as well?

Can we simply open mistakenly intercepted Intends with the default browser?

It is probably not possible to change the "manifest" of the app during runtime or?

PrimozRatej commented 1 year ago

@luke- Getting the intent for fully dynamic links is not possible. The definition for URL intents is defined in build time so we need to know/have some kind of URL naming scheme for those URLs beforehand.

We can open mistakenly intercepted Intents in the browser, but that would mean redirecting the intent to the app, the app will be opened and will redirect the user to the browser. Example: We want to intercept //{something}.humhub.com but not //www.humhub.com (Home page) We do not have the option to exclude intents in AndroidManifest. The intent for //www.humhub.com will still be fired but we can handle that inside the code at runtime but it will force us to open an app.

The "manifest" of the app can be changed during runtime which would mean clearing the config. for the current manifest and save value for the intent if we want to do so.

My suggestion would be if we really want to cover all the native functionalities such as push notifications intents, share etc. to start looking into Flavors

luke- commented 1 year ago

@PrimozRatej Can we use a parameter or extension to identify HumHub requests?

e.g. we could add a query param humhub=1 to all Notification and Activity Links. e.g. https://intranet.example.com/notification/12354?humhub=1&someother=5

PrimozRatej commented 1 year ago

Yes, that will work but it needs to be really something identical something that only we would use.

PrimozRatej commented 1 year ago

@luke- Update: This will not work for query params, the problem is that part after the "?" mark is not matched against anything (filter ignores it). Source: https://stackoverflow.com/questions/7277480/match-http-parameters-in-url-with-android-intent-filters Reserved chars: https://stackoverflow.com/questions/23539632/android-intent-filter-detect-url-with-http-get-params

luke- commented 1 year ago

@PrimozRatej Thanks for the info. I would postpone this feature to a later app version.