Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening ntfy.sh link in a browser on Android opens the app and subscribes to the topic if the app is installed #20

Closed
Copephobia opened this issue Nov 24, 2021 · 13 comments
Labels
android-app ntfy Android app enhancement New feature or request in-progress 🏃 I'm working on this right now

Comments

@Copephobia
Copy link
Contributor

A scenario may be:

  • I have the ntfy.sh app installed on my Android device
  • A browser page or application (like Slack) has a URL to a ntfy.sh topic

If I click on the ntfy.sh link, it will attempt to open the app and subscribe to the topic, so that I can view it from there.

If I do not have the ntfy.sh link, it will display the web page for that topic.

@binwiederhier
Copy link
Owner

binwiederhier commented Nov 24, 2021

I like this idea. And it should not be hard to implement.

@binwiederhier binwiederhier added android-app ntfy Android app enhancement New feature or request in-progress 🏃 I'm working on this right now labels Nov 26, 2021
@binwiederhier
Copy link
Owner

Re-opening this, since I removed the feature in the latest commit. Android is not allowing me to register reg-ex patterns of URLs and the wildcard stuff seems incredibly buggy. I spent two+ hours with it yesterday and it's not worth it for now.

@binwiederhier binwiederhier reopened this Dec 13, 2021
@binwiederhier binwiederhier removed the in-progress 🏃 I'm working on this right now label Dec 13, 2021
@gc-ss
Copy link

gc-ss commented Dec 31, 2021

Let's simplify it first?

  1. Instead of handling http(s) links, let the app respond to ntfy links and the app registers to handle ntfy links
  2. Have a little text template that spits out the http(s) links and the ntfy link to send to people (instead of just http(s) link)

Is this a possibility?

@binwiederhier
Copy link
Owner

I wrote a whole long paragraph about why that's difficult and then I read your comment again. You just want a Share button that prints two links, one of which will open the app?

I don't know if Android will highlight and let you click ntfy:// links, probably not, but it's worth a try definitely.

And we'd still need a solution for the web UI.

@gc-ss
Copy link

gc-ss commented Dec 31, 2021

I wrote a whole long paragraph about why that's difficult and then I read your comment again

Philipp, then I did a poor job of conveying my intention. In case you happen to have that paragraph, I would really appreciate reading it. If it's gone, can you just type in the highlights so I can figure out what disconnect existed (before you read my comment again)?

You just want a Share button that prints two links, one of which will open the app?

Right. My thought is that the app can register itself with ntfy:// links and have greater control

And we'd still need a solution for the web UI.

I believe we can still use ntfy:// links or something similar (the client app can register itself with ntfy:// links)

@12nick12
Copy link
Sponsor

I'm not a dev, but going from what has been spoken in the issue and my limited knowledge of stuff, you could just add a ntfy: link in the web page if you can get ntfy app to open ntfy: links. Kind of link how tel: opens the dialer and mailto: opens email.

@binwiederhier
Copy link
Owner

That would be easy to do, but then it looks horribly broken for people that don't have the app installed.

@12nick12
Copy link
Sponsor

You could word something like "if you have the app installed hit THIS link"

@jhotmann
Copy link
Contributor

jhotmann commented Mar 31, 2022

For me, having the app able to handle ntfy:// links would be enough as I mainly just want to be able to open the app to a specific topic via Tasker. But having a ntfy:// link show up if you open a topic in a mobile browser could also be handy.

I wrote a custom Owntracks server implementation and part of it includes device configuration generation. It creates an owntracks:// links with the configuration data base64 encoded and is clickable from the Android and iOS browsers. The links aren't highlighted/clickable in messaging and other apps, though.

@binwiederhier
Copy link
Owner

Sorry I never responded to this. This sounds easy enough. I should be able to whip that up at some point. There are just so many tickets :-D

@binwiederhier
Copy link
Owner

(I'm starting work on this)

So if I implement ntfy://ntfy.sh/mytopic that opens the topic in the Android app and subscribes to it, that would be enough?

I wonder if I should structure the link differently, so that other actions are supported in the future, like ntfy://ntfy.sh/mytopic?action=subscribe, or ntfy://subscribe/ntfy.sh/mytopic, ...

I suppose I could iterate on it, so I think I'll just start with ntfy://ntfy.sh/mytopic.

@binwiederhier
Copy link
Owner

binwiederhier commented Apr 12, 2022

https://github.com/binwiederhier/ntfy-android/pull/24/files implements this:

  • ntfy://myhost.lan/mytopic --> subscribes to https://myhost.lan/mytopic (if not already subscribed) and shows it
  • ntfy://myhost.lan/mytopic?secure=false --> subscribes to http://myhost.lan/mytopic (if not already subscribed) and shows it

I think this is all there is to it. All that's missing is documentation for it.

To test:

adb shell am start -W -a android.intent.action.VIEW -d "ntfy://10.0.2.2/abc?secure=false" io.heckel.ntfy

@binwiederhier
Copy link
Owner

Done. Will be in the next Android release. Added docs too, which will be in the next server release:

220412 20-09-42 Selection 001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android-app ntfy Android app enhancement New feature or request in-progress 🏃 I'm working on this right now
Projects
None yet
Development

No branches or pull requests

6 participants
@binwiederhier @Copephobia @jhotmann @12nick12 @gc-ss and others