having problem while showing the notification on ios physical device, not sure where I made mistakes the ios notification works on Simulator but when I test it on a physical iPhone it did not work.
setUpLocalNotification() async {
//Local Notification Configuration--------
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
var initializationSettingsAndroid = AndroidInitializationSettings('logo');
var initializationSettingsIOS = IOSInitializationSettings(
requestSoundPermission: true,
requestBadgePermission: true,
requestAlertPermission: true,
onDidReceiveLocalNotification: onDidReceiveLocalNotification,
);
var initializationSettings = InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: onSelectNotification);
//end local notification
}
here is what have
Future onDidReceiveLocalNotification(
int id, String title, String body, String payload) async {
// display a dialog with the notification details, tap ok to go to another page
showDialog(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: Text(title),
content: Text(body),
actions: [
CupertinoDialogAction(
isDefaultAction: true,
child: Text('Ok'),
onPressed: () async {
Navigator.of(context, rootNavigator: true).pop();
},
)
],
),
);
}
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print('---------------, message recied');
_showNotificationWithDefaultSound(message);
},
onLaunch: (Map<String, dynamic> message) async {
print('test on laucnh---');
navigateUser(message);
},
onResume: (Map<String, dynamic> message) async {
print('------=-=-=-=');
navigateUser(message);
// TODO optional
},
);
on the message does work on the simulator and android physical device but when it comes to iOS notification works on Simulator but not on Physical Device
Future _showNotificationWithDefaultSound(Map<String, dynamic> message) async {
var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'your chnnel id', 'your channel name', 'your channel description',
importance: Importance.Max, priority: Priority.High);
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
98,
message['notification']['title'],
message['notification']['body'],
platformChannelSpecifics,
payload: JsonEncoder.withIndent(" ").convert(message),
);
}