Skip to content

Allow use upstream-base-url config for Android app#82

Open
kruton wants to merge 1 commit into
binwiederhier:mainfrom
kruton:android_poll_request
Open

Allow use upstream-base-url config for Android app#82
kruton wants to merge 1 commit into
binwiederhier:mainfrom
kruton:android_poll_request

Conversation

@kruton

@kruton kruton commented May 26, 2024

Copy link
Copy Markdown

This mirrors the logic used for instant notifications in the iOS app:

  • When a user subscribes to a topic, the app will subscribe to Firebase using sha256(baseUrl + topic).

  • When a "poll_request" call is received from Firebase, the app will look up the sha256(baseUrl + topic) of all subscriptions in the database and see if the poll_request topic matches that. If it does, it will poll the original server using the stored baseUrl from the subscriptions database.

This fixes binwiederhier/ntfy#358

This mirrors the logic used for instant notifications in the iOS app:

 * When a user subscribes to a topic, the app will subscribe to
   Firebase using sha256(baseUrl + topic).

 * When a "poll_request" call is received from Firebase, the app will
   look up the sha256(baseUrl + topic) of all subscriptions in the
   database and see if the poll_request topic matches that. If it does,
   it will poll the original server using the stored baseUrl from the
   subscriptions database.
@kruton
kruton force-pushed the android_poll_request branch from d1fc271 to eee093f Compare May 26, 2024 23:30
@kruton

kruton commented Nov 21, 2024

Copy link
Copy Markdown
Author

@binwiederhier any interest in merging this?

@binwiederhier

Copy link
Copy Markdown
Owner

I like this a lot. Let me see if I can get this merged. Thanks for the contribution, and sorry it took sooooooo long to respond.

@binwiederhier

binwiederhier commented Dec 29, 2025

Copy link
Copy Markdown
Owner

I was playing with this for a bit, and while the delivery works just fine, the UI does not allow de-selecting instant delivery for topics from other servers. I also think we can't just unhide the [ ] Instant delivery checkbox without a warning of sorts, because that'll lead to notifications not being delivered.

I will play with it more (https://github.com/binwiederhier/ntfy-android/tree/android_poll_request).

Also, I just realized you made "ConnectBot". I randomly clicked on your name and website. Very cool. Thank you for that!!

val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val workName = "${PollWorker.WORK_NAME_ONCE_SINGE_PREFIX}_${baseUrl}_${topic}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? "SINGE" -> "SINGLE"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that could be changed in another commit. It was an existing spelling mistake.

@kruton

kruton commented Dec 29, 2025

Copy link
Copy Markdown
Author

I was playing with this for a bit, and while the delivery works just fine, the UI does not allow de-selecting instant delivery for topics from other servers. I also think we can't just unhide the [ ] Instant delivery checkbox without a warning of sorts, because that'll lead to notifications not being delivered.

So you're worried about self-hosted ntfy instances that either have no upstream-base-url (and optional upstream-access-token) or deliver a message with Firebase: no header? I think we can disregard the second because that seems intended on the user's part.

For the first case, it seems like a documentation issue. A descriptive piece of text could be added near the "[ ] Instant notification" checkbox saying that if the server does not have the "upstream server" configured, delivery might be delayed without that checked. It could link to the website for more explanation. However, I don't know how many support requests this will generate. Maybe just indicate it's always safe to keep "Instant delivery" enabled.

Actually, I think there is an existing issue that if you set a different "Default server" you can't check the "Instant delivery" box without clicking on "Use another server" anyway. This may cause delivery latency to increase if your "Default server" doesn't match the appBaseUrl.

I will play with it more (https://github.com/binwiederhier/ntfy-android/tree/android_poll_request).

Also, I just realized you made "ConnectBot". I randomly clicked on your name and website. Very cool. Thank you for that!!

No problem. I've recently begun to modernize that app after a significant lack up updates in recent years as well.

@tecosaur

tecosaur commented Jul 8, 2026

Copy link
Copy Markdown

Heyo 👋 I've arrived here from binwiederhier/ntfy#1195 after noticing my system report Ntfy as responsible for >20% of my battery usage. It would be rather cool to see this move forward!

@ArbiterGR

Copy link
Copy Markdown

This would be amazing and make ntfy usable for my usecase. Please make this happen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: Implement poll_request mode (similar to iOS)

5 participants