pusher / push-notifications-flutter

Official Pusher Beams Flutter client plugin (iOS, Android and Web), receive notifications easily on your Flutter application with Pusher Beams.
https://pub.dev/packages/pusher_beams
MIT License
10 stars 21 forks source link

Foreground incoming message handling support #16

Closed fbenevides closed 2 years ago

fbenevides commented 2 years ago

In this PR, we start supporting a way to handle push notifications when it arrives on a user's device, and the app is in the foreground. This feature already exists on Android, iOS and Web, but it was missing on FlutterSDK.

Usage

The client needs to implement a function that receives push notification content as a Map.

..
PusherBeams.instance.onMessageReceivedInTheForeground(_onMessageReceivedInTheForeground);
..
void _onMessageReceivedInTheForeground(Map<Object?, Object?> data) {
    // handling message
}

Screenshot

Android / iOS working. ("Web" still missing). I've sent those messages using REST API just for testing.

ezgif com-gif-maker (2)ezgif com-gif-maker (3)

Next steps

kashiflab commented 11 months ago

I updated pusher beam to the latest version and getting this error. @fbenevides Unhandled Exception: type '_Map<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>' in type cast