Closed sgarchavada closed 2 years ago
Hi @sgarchavada,
Please ensure you implemented the backgroundNotificationListener
method, as it is missing from your implementation above.
Add the following method to your main.dart
file, right after the import
statements, and outside any Widget class declaration, to process push notifications in the background via a Flutter background isolate:
// Please place this code in main.dart,
// After the import statements, and outside any Widget class (top-level)
void backgroundNotificationListener(Map<String, dynamic> data) {
// Print notification payload data
print('Received notification: $data');
// Notification title
String notificationTitle = 'MyApp';
// Attempt to extract the "message" property from the payload: {"message":"Hello World!"}
String notificationText = data['message'] ?? 'Hello World!';
// Android: Displays a system notification
// iOS: Displays an alert dialog
Pushy.notify(notificationTitle, notificationText, data);
// Clear iOS app badge number
Pushy.clearBadge();
}
Check out the Pushy Flutter Demo main.dart for reference.
pushy_flutter: ^2.0.1
Here's my implementation
here's the log I am receiving when I send push to this device.
But notification is not appearing
I tried another demo, its working fine. but not in my real app. is this because I am wrapping this implementation in sentry?
Only tested this android.
Also Its say Invoking notification listener in foreground (no isolate), though my app is in background state.