You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PushNotifications.md
+47-1Lines changed: 47 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -185,7 +185,47 @@ import ably_flutter
185
185
- Your device is now ready to receive and display user notifications (called alert notifications on iOS and notifications on Android) to the user, when the application is in the background.
186
186
- For debugging: You could use the Ably dashboard (notification tab) or the Push Admin API using another SDK to ensure the device has been subscribed by listing the subscriptions on a specific channel. Alternatively, you can list the push channels the device or client is subscribed to: `final subscriptions = channel.push.listSubscriptions()`. This API requires Push Admin capability, and should be used for debugging. This means you must use an Ably API key or token with the `push-admin` capability.
187
187
188
-
### Notification Permissions (iOS only)
188
+
### Notification Permissions
189
+
190
+
SDK users are free to choose any library they prefer for managing device permissions, allowing flexibility based on their project requirements.
191
+
192
+
#### Notification Permissions using `permission_handler` package
193
+
194
+
However, we recommend using the [flutter-permission-handler](https://github.com/baseflow/flutter-permission-handler) package due to its reliable cross-platform support for both iOS and Android.
195
+
196
+
> [!NOTE]
197
+
> Requesting notification permissions is only necessary for Android 13 (API level 33) and above. For earlier Android versions, notification permissions are granted by default.
198
+
199
+
To implement it in your app, follow these steps:
200
+
201
+
1. Add `permission_handler` to your `pubspec.yaml` dependencies.
202
+
2. Use `Permission.notification.request()` to request notification permissions across both iOS and Android.
> This approach to requesting notification permissions is deprecated for two key reasons:
225
+
>
226
+
> 1.**Platform Limitation:** The `Push#requestPermission` method only works for iOS and does not support Android, which means developers have to rely on platform-specific code.
227
+
>
228
+
> 2.**Client Initialization Dependency:** The `requestPermission` method is tied to the Ably Push object, which requires an initialized Ably client to request permissions. This is not an ideal design, as permission requests should not depend on initializing the Ably client. Instead, permission handling should be a standalone utility function.
189
229
190
230
Requesting permissions:
191
231
@@ -208,6 +248,12 @@ if (Platform.isIOS) {
208
248
}
209
249
```
210
250
251
+
> [!NOTE]
252
+
> We are currently working on adding built-in support for notification permissions as a utility function within our SDK.
253
+
> This update will simplify permission handling and provide a unified solution for both iOS and Android.
254
+
> You can subscribe to [the issue](https://github.com/ably/ably-flutter/issues/545) to receive updates on our progress.
255
+
> Once implemented, using third-party libraries like flutter-permission-handler will be optional for managing notification permissions.
0 commit comments