Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/android/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions templates/flutter/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading