humhub / app

18 stars 7 forks source link

Email notification "View Online" link opens in the browser instead of the mobile app #96

Closed marc-farre closed 9 months ago

marc-farre commented 11 months ago

When receiving a notification by email, if you click on the "View Online" link, Humhub is open in the default browser instead of the mobile app.

marc-farre commented 10 months ago

@PrimozRatej I think this is an important problem. Thanks!

PrimozRatej commented 10 months ago

Hello @marc-farre, @luke- I prepared a dok. on how we can implement this.

https://resilient-stingray-baf.notion.site/App-Links-Android-and-Universal-links-iOS-7dd3cf9b0951456fa2d58fabe253e78a

I'm more in favor of the second approach. Maybe for the first take, we do not need to do any CI/CD magic, but we could implement it manually for the most used instances e.g. https://www.humhub.com/, https://community.humhub.com/ ...

marc-farre commented 10 months ago

Thanks @PrimozRatej for your researches.

Option 1 (Proxy)

@luke- if this is a possibility for you, I think it's the best solution, but I suggest to add a setting in Humhub allowing the system administrator to choose if he want's URLs in email to go throw Humhub host redirection or not.

Maybe this could be a paid option as it uses Humhub server resources?

This possibility could also be added into the Push Notifications module or another paid module?

Rocket.chat uses this option:

android:host="go.rocket.chat"

https://github.com/RocketChat/Rocket.Chat.Android/blob/develop/app/src/main/AndroidManifest.xml#L50

The URL in an email to redirect to a message looks like this: https://go.rocket.chat/room?rid=xxx&mid=xxx&host=sub.domain.tld&path=channel%2Fchannel_name%3Fmsg%3xxx

Option 2 (CI/CD Magic)

For me, this is a possibility, as there are too many Humhub instances.

Alternative with a custom scheme

Using the humhub:// scheme (see Custom URL schemes: https://blog.flutter.wtf/flutter-deep-link/).

We coud add a button in the email called "View in the app" (in addition to the "View online" button). And the URL will start with humhub://.

I don't like very much this solution because it's not very UX friendly.

marc-farre commented 10 months ago

@PrimozRatej maybe there is an alternative to Option 1 using the my_custom_name.page.link possibility offered by Firebase dynamic links: https://firebase.google.com/docs/dynamic-links

It's free, and it could avoid the need of Humhub server redirection if I understand well.

This way, each for Humhub instance, the system admin would creates my_custom_name.page.link on his Google account, and save the link in the Humhub configuration, so that Humhub changes the URLs in emails to start with https://my_custom_name.page.link.

luke- commented 9 months ago

@PrimozRatej @marc-farre Thanks for your research and suggestions!

In fact, a redirect service like https://go.humhub.com/... seems to be the best solution. Even if there are drawbacks here.

To sum up: When enabled (via Admin settings), all outgoing e-mail links (notification & activities) should be rewritten from https://example.com/notification/123 to https://go.humhub.com/example.com/notification/123. There should be a clear notice on this behavior. The server costs should be low that we can offer the service free of charge for everyone. However, we must be able to stop abuse. Maybe we also provide a Firebase dynamic link Provider Option in future.

@marc-farre Are there any other place exception Notification / Activity Summary e-mails where this rewrite would be useful?

A big disadvantage is of course that all link calls from emails (even from non-app users) go through us and thus a privacy problem could arise. @Semir1212

Individual app versions do not need this, of course.

We need to see if we can implement this into the fcm_push module or we need to add this into the core.

marc-farre commented 9 months ago

Thanks @luke-, that's fine.

Are there any other place exception Notification / Activity Summary e-mails where this rewrite would be useful?

If we rewrite URLs starting with the base URL (the one in the general settings) via humhub\components\mail\Mailer, I cannot see any exception, except in the Mass Notification module which can send emails via a Brevo campaign, but I'll deal with it.

if we can implement this into the fcm_push module

Perhaps with an event in humhub\components\mail\Mailer which can be triggered by the fcm_push module?

luke- commented 9 months ago

@PrimozRatej Can you please implement following behavior:

In future with Flutter Flavors we need to make this URL configurable.

Thanks!

PrimozRatej commented 9 months ago

The #113 is ready on the app side. I'm appending the apple-app-site-association and assetlinks.json files.

association_files.zip

luke- commented 9 months ago

@PrimozRatej Thanks, when we need the these files?

PrimozRatej commented 9 months ago

Hey @luke- , Those files need to be hosted on the proxy server. They are a way to identify that this particular web app can be opened inside the HumHub app. This allows the app to open the link inside an app without a popup occurring every time (just the first time when the association is made for Android) and working universal links (for iOS).

If the proxy will be https://go.humhub.com they need to be publicly available under https://go.humhub.com/.well-known as application/json, here is the example.

Documentation Android Documentation iOS

luke- commented 9 months ago

@PrimozRatej Thanks works fine for me on Android. Any idea why the Apple Deployment fails?

@marc-farre Can you also test it? You need a new FCM-Push Module Version v2.0.0-beta.8

PrimozRatej commented 9 months ago

Hey @luke- forgot to change it back to prod. distribution profile, it should work now.

marc-farre commented 9 months ago

@PrimozRatej @luke- It's now working fine with app v1.0.75, Push notification module v2.0.0-beta.9 and Humhub v1.15-beta-2! Thanks!