flutter_local_notifications icon indicating copy to clipboard operation
flutter_local_notifications copied to clipboard

onDidReceiveNotificationResponse not working (Android)

Open admincode1 opened this issue 5 months ago • 0 comments

`@pragma('vm:entry-point')

void onDidReceiveNotificationResponse( NotificationResponse notificationResponse) async { final prefs = await SharedPreferences.getInstance(); final String? payload = notificationResponse.payload; if (notificationResponse.payload != null) { debugPrint('notification payload: $payload'); } }`

`Future notificationInitialize() async {

const initializationSettingsAndroid = AndroidInitializationSettings('app_icon6'); const InitializationSettings initializationSettings = InitializationSettings(android: initializationSettingsAndroid); flutterLocalNotificationsPlugin.initialize(initializationSettings, onDidReceiveNotificationResponse: onDidReceiveNotificationResponse); final NotificationAppLaunchDetails? notificationAppLaunchDetails = await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails(); String? payload = notificationAppLaunchDetails!.notificationResponse?.payload; }`

AndroidManifest:

<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" /> <receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/> </intent-filter> </receiver> <receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver" /> .... <service android:name="com.dexterous.flutterlocalnotifications.ForegroundService" android:exported="false" android:stopWithTask="false"/>

admincode1 avatar May 21 '25 02:05 admincode1