Giter Site home page Giter Site logo

Comments (10)

binwiederhier avatar binwiederhier commented on May 4, 2024 1

Thank you very much for the write-up and the fantastic explanation.

Broadcasting intents

I love the idea of just broadcasting an intent and thereby integrating with other apps. It's easy and gets the job done.
I'll certainly do that when I get to it. Sounds like a fantastic feature!

I personally wanted to not use app,

😢 May I ask what the reason is? You don't like the foreground service?

but just fetch for messages every 5 min

The smallest possible interval that Android allows (without a foreground service) is 15 minutes (via WorkManager). I had plans to allow people to configure an interval to let them choose:

  • instant (requires foreground service)
  • 1min (requires foreground service)
  • 5min (requires foreground service)
  • 15min (does NOT require foreground service)
  • ..

But I haven't gotten to that yet. (Edit: Just created a ticket: #32)

So I tryed curl: curl -s "ntfy.sh/mytopic/json?since=all"

This will keep the connection open forever, so unless you send messages to the topic it won't return anything other than the open message and the other messages already in the channel:

{"id":"4nMJJOYQYP","time":1638625810,"event":"open","topic":"mytopic"}
{"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"}
(connection stays open)

If you want the connection to terminate after, you can add poll=1, like this:

curl -s "ntfy.sh/mytopic/json?since=all&poll=1"
{"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"}

Or are you saying you're not receiving ANY output from the curl? May I suggest you drop the -s and maybe do a curl -v, like this:

curl -v "ntfy.sh/mytopic/json?since=all&poll=1"
*   Trying 46.163.76.87...
* TCP_NODELAY set
* Connected to ntfy.sh (46.163.76.87) port 80 (#0)
> GET /mytopic/json?since=all&poll=1 HTTP/1.1
> Host: ntfy.sh
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Sat, 04 Dec 2021 13:51:59 GMT
< Server: Apache/2.4.41 (Ubuntu)
< Access-Control-Allow-Origin: *
< Content-Type: application/x-ndjson; charset=utf-8
< Transfer-Encoding: chunked
< 
{"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"}
* Connection #0 to host ntfy.sh left intact

That'll show any errors.

from ntfy.

binwiederhier avatar binwiederhier commented on May 4, 2024 1

just f-droid version seems to be a little broken

Oh no. I just remembered this, sorry it took so long.
Can you elaborate on how it is broken? Can you maybe describe or take a video. I'd love to fix this if this is an issue.

option without another foreground service

So the only option to do this without another foreground service and without FCM is with polling every X minutes. With WorkManager (which is the only approved way these days), you can check only every 15 minutes. That's the shortest interval that you can set. Everything else won't work.

My plan is to do this as part of #10 is this:

Per subscription, allow you to set:

(x) Instant delivery
( ) Check every minute (requires foreground service)
( ) Check 5 minutes (requires foreground service)
( ) Check 10 minutes (requires foreground service)
( ) Check 15 minutes
( ) Check 30 minutes

I can imagine that even the "Check every 5 minutes" option will likely consume almost no battery, since the majority of the time we're just sleeping.

from ntfy.

FrameXX avatar FrameXX commented on May 4, 2024

Also. I personally wanted to not use app, but just fetch for messages every 5 min or so with curl, because that's enough for my purpose and I don't need instant delivery (but some users might want, that's why I opened this issue). So I tryed curl:

curl -s "ntfy.sh/mytopic/json?since=all"

but it won't return me any data. (No, I didn't forgot to change mytopic to my real topic.) I also tryed changing json to raw but it didn't helped. Am I doing something wrong?

EDIT: It was MacroDroid fault. Your command works, I tryed it in another shell app.

from ntfy.

FrameXX avatar FrameXX commented on May 4, 2024

May I ask what the reason is? You don't like the foreground service?

Your app is totally fine (just f-droid version seems to be a little broken). I have budget phone from 2018 and I have already some apps using foreground services, so I searched for an option without another foreground service. I may still use the app, I will see, but it's always good to know what all options I have. I was just discovering if this is a possibility. Also polling for messages like this doesn't require Google Play services (,which I have on my phone, but some people may not).

If you want the connection to terminate after, you can add poll=1

Thank you! Adding poll=1 helped and I get the output.

from ntfy.

FrameXX avatar FrameXX commented on May 4, 2024

Oh no. I just remembered this, sorry it took so long.
Can you elaborate on how it is broken? Can you maybe describe or take a video. I'd love to fix this if this is an issue.

It's missing an option of instant delivery when adding a topic, which I would understand (I presume it's because it does not use Google Play Services), but after creating a subscription it shows a persistent notification that states 'You are subscribed to one instant delivery topic', which is kind of confusing because I know delivery should not be instant. But what I don't know is that there will be no notification delivery at all. I don't know what poll time is used by default if any, but I send message to topic, waited 5 minutes and nothing happened. It won't send me the notification and I need to open the app to see the message and even after opening the

OKAY, so notifications started suddenly working and they are instant.

I swear they didn't worked before. (My bad. I am suspicious that I had do not disturb mode on, which bloked notifications from showing up).

But still there are some weird things. As I stated there's missing an option on instant delivery and it seems to be instant by default. When I am on topic messages page and tap on lightning icon in top menu it does nothing and just says that instant delivery is enabled. Overally f-droid version has less options? Why? Is it that you updated the app, but f-droid repository didn't updated since?

So this all seems to be just my own stupidity after all. Sorry for wasting your time with this.

With WorkManager (which is the only approved way these days), you can check only every 15 minutes. That's the shortest interval that you can set. Everything else won't work.

Totally understand

from ntfy.

binwiederhier avatar binwiederhier commented on May 4, 2024

I am suspicious that I had do not disturb mode on, which bloked notifications from showing up

Oh this is a clue. I will investigate that.

I also had the suspicion that if you mess with the "Subscription Service" notification channel as described here (https://ntfy.sh/docs/subscribe/phone/#instant-delivery), ie. when you toggle the "Subscription Service" off, that that actually messes with the foreground service. But it's only a suspicion.

OKAY, so notifications started suddenly working and they are instant.

Yey :-D

But still there are some weird things. As I stated there's missing an option on instant delivery and it seems to be instant by default. When I am on topic messages page and tap on lightning icon in top menu it does nothing and just says that instant delivery is enabled. Overally f-droid version has less options? Why? Is it that you updated the app, but f-droid repository didn't updated since?

Okay so this is a UI issue that knew may cause confusion, but I wanted the F-Droid version out, ...

The thing is this:

On Google Play, if you use ntfy.sh, you have the choice between instant or not, because of Firebase, so the "[ ] Instant delivery" checkbox is there.

On F-Droid, even when using ntfy.sh, because we don't have Firebase, the "[ ] Instant delivery" is not there, because ALL subscriptions are "instant delivery".

Bottom line: I agree that this is terribly confusing, and I will revamp this when I get to #32, i.e. what I described here: #31 (comment)

from ntfy.

binwiederhier avatar binwiederhier commented on May 4, 2024

As per the conversation in https://www.macrodroidforum.com/index.php?threads/ntfy-sh-update-post.1531/, I'm reposting what was discussed there:

Alright, that all sounds reasonable I think, and not that hard to do. Let me know if I got that right:

  1. MD -> ntfy.sh: Publish messages via GET, something like, like: GET /mytopic/send?title=abc&tags=tag1,tag2&priority=5&... --- This is highly unorthodox, since GET requests are supposed to be idempotent. I don't like this a ton, but if it's absolutely needed ....

  2. MD -> Ntfy app: Publish messages via broadcast intents to Ntfy: So MD could broadcast an intent and Ntfy would catch it and do the PUT/POST request to send the message. This sounds like an alternative to (1). Is this better or worse than (1) in your opinion?

  3. ntfy.sh -> Ntfy -> MD: Ntfy app should broadcast all received messages as intents so that MD can catch it. Correct?

I'll check out pushbullet.

from ntfy.

binwiederhier avatar binwiederhier commented on May 4, 2024

Pretty much done: binwiederhier/ntfy-android@323e013

from ntfy.

binwiederhier avatar binwiederhier commented on May 4, 2024

I'll leave this open until it's released and tested

from ntfy.

binwiederhier avatar binwiederhier commented on May 4, 2024

Done in 1.4.0

from ntfy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.