From b4ea88332c7cce01be79896a1438d768bd0d866b Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 17 Oct 2026 17:47:10 +0100 Subject: [PATCH] docs(flutter,android): keep the push subscription open in README samples --- templates/android/README.md.twig | 4 ++-- templates/flutter/README.md.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/android/README.md.twig b/templates/android/README.md.twig index bcf1d8c2ad..95860db36c 100644 --- a/templates/android/README.md.twig +++ b/templates/android/README.md.twig @@ -65,10 +65,10 @@ val push = Push(client, context) val subscription = push.subscribe { message -> Log.d("Appwrite", "${message.topic}: ${message.data}") } - -subscription.unsubscribe() ``` +Keep `subscription` while you want messages, and call `subscription.unsubscribe()` when you stop listening, for example in your activity's `onDestroy()`. + ### Background delivery A subscription with `background = true` keeps delivering after the app is backgrounded, its process is killed, or the device restarts, until it is unsubscribed or `push.close()` is called (do this on sign-out). No service is kept running: a scheduled job and alarm wake the app every 15 to 60 seconds to reconnect, and the broker replays what was sent in between (`retry = true`). It reconnects with the credential saved at subscribe time, so use a session (`client.setSession(...)`), not a short-lived JWT. diff --git a/templates/flutter/README.md.twig b/templates/flutter/README.md.twig index bcc66b70ac..93242875bd 100644 --- a/templates/flutter/README.md.twig +++ b/templates/flutter/README.md.twig @@ -67,10 +67,10 @@ final push = Push(client); final subscription = await push.subscribe('news', (message) { print('${message.topic}: ${message.data}'); }); - -subscription.unsubscribe(); ``` +Keep `subscription` while you want messages, and call `subscription.unsubscribe()` when you stop listening, for example in your widget's `dispose()`. + ### Background delivery on Android A subscription with `background: true` keeps delivering after the app is backgrounded, killed or the device restarts, until it is unsubscribed or `push.close()` is called (do this on sign-out). The plugin saves the subscription, and a scheduled job and alarm wake the app every 15 to 60 seconds to reconnect; the broker replays what was sent in between (`retry: true`). While the app is not on screen, each message is posted as a notification that opens the app. It reconnects with the credential saved at subscribe time, so use a session rather than a short-lived JWT.