I want to show periodic notification using workmanager.I need context to navigate when user tap on notification but context is not available in background task.How to solve this issue.I have passed the context as inputData to workmanager but gives String is not subtype of BuildContext.
Workmanager().registerPeriodicTask("periodicTaskId", "periodicTaskName",
inputData: Map.from({"context": context.toString()}),
frequency: const Duration(minutes: 15));
@pragma('vm-entry-point')
dispatcher() {
Workmanager().executeTask((taskName, inputData) async {
try {
print(inputData.toString());
BuildContext context = inputData!['context'];
await ShowNotificationClass().showNotification(context);
} catch (e) {
print(e.toString());
}
return Future.value(true);
});
}