Closed chanmaoinc closed 4 years ago
Hi @chanmaoinc, Thanks so much for your inquiry.
This feature is indeed high on our list -- you can expect completion in the next 4 weeks or so. We'll be sure to let you know once it's ready!
Thanks and looking forward.
Hi @anthonycmeow @chanmaoinc, Great news! We have just finished integrating this functionality into the Pushy Flutter SDK.
Call the Pushy.setNotificationClickListener((data) => {})
method from your application to listen for when the user taps your notifications:
// Listen for push notification clicked
Pushy.setNotificationClickListener((Map<String, dynamic> data) {
// Print notification payload data
print('Notification clicked: $data');
// Extract notification messsage
String message = data['message'] ?? 'Hello World!';
// Display an alert with the "message" payload value
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Notification clicked'),
content: Text(message),
actions: [ FlatButton( child: Text('OK'), onPressed: () { Navigator.of(context, rootNavigator: true).pop('dialog'); } )]
);
});
// Clear iOS app badge number
Pushy.clearBadge();
});
This functionality is supported on both Android and iOS. Inside this method, you can access the notification payload which was clicked and direct the user to the relevant page in your Flutter app, or execute other custom logic on notification click.
To be able to access this method, please update the Pushy Flutter SDK in your app by editing the pubspec.yaml
in the root directory of your project and updating the pushy_flutter
package version to 1.0.8
:
pushy_flutter: 1.0.8
Then, run flutter pub get
to fetch the new package.
Run your app and give it a go! Please let us know if you face any issues.
Awesome!
When will Flutter SDK support "Listen for Notifications (Clicked)" like the React Native SDK? We are looking for navigating to specific page via notification click event. Thanks.