jr1221 / ntfy_dart

Dart wrapper around the ntfy API
5 stars 2 forks source link

Received messages don't get shown in notification drawer #2

Open KrasnokutskiyEA opened 6 months ago

KrasnokutskiyEA commented 6 months ago
  1. subscribing to topic - cat:
import 'package:ntfy_dart/ntfy_dart.dart';

const String topics = 'cat';

client = NtfyClient(
    basePath: Uri(
    scheme: 'http',
    host: '192.168.1.69',
    port: 9900,
  ),
);

stream = (await client?.getMessageStream([topics]));

listening = stream?.listen((event) {
  if (event.event == EventTypes.message) {
    print('${event.message}');
    return;
  } else {
    print('received ${event.event}');
  }
});
  1. Sending message:
curl -d "Hello!" 192.168.1.69:9900/cat
  1. Result: Message gets printed in console as expected, but it doesn't show up in notification drawer unless corresponding subscription is manually added in ntfy app on a device.

Is it meant to be that way? Is this package only responsible for handling received messages (programmatically), but not for showing them in notification drawer as e.g. awesome_notifications does?

Thanks for package!

@jr1221

Pavel401 commented 4 months ago

@jr1221 Hey, thanks for creating this package, how do we show the notification in the notification drawer?.

@KrasnokutskiyEA Did you find any solution ?

jr1221 commented 4 months ago

Hi all, Sorry I never responded at first. I am a little confused by what you both mean. If you would like a notification to occur like the official ntfy mobile app, you must implement your own notification library and attach the output of the stream to the notification library.

This library is for dart only, therefore has no knowledge of flutter or mobile app related functions.

Hopefully this helps!