notify method
Implementation
Future<void> notify(ContractBase? contract, String payload) async {
const DarwinNotificationDetails iOSPlatformChannelSpecifics =
DarwinNotificationDetails(
presentAlert:
true, // Present an alert when the notification is displayed and the application is in the foreground (only from iOS 10 onwards)
// presentBadge: true, // Present the badge number when the notification is displayed and the application is in the foreground (only from iOS 10 onwards)
presentSound:
true, // Play a sound when the notification is displayed and the application is in the foreground (only from iOS 10 onwards)
// sound: String?, // Specifics the file path to play (only from iOS 10 onwards)
// badgeNumber: int?, // The application's icon badge number
// attachments: List<IOSNotificationAttachment>?, (only from iOS 10 onwards)
// subtitle: String?, //Secondary description (only from iOS 10 onwards)
// threadIdentifier: String? (only from iOS 10 onwards)
);
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails(
'bizdoc',
'BizDoc',
importance: Importance.max,
priority: Priority.high,
);
const NotificationDetails platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics,
iOS: DarwinNotificationDetails());
if (contract is NewMail) {
final actions = session.profile.actions
.where((element) => contract.model.actions!.contains(element.name));
try {
await flutterLocalNotificationsPlugin.show(
contract.model.id,
contract.model.subject,
contract.model.summary,
platformChannelSpecifics,
payload: payload);
} on Exception catch (e) {
print(e);
}
} else if (contract is NewChat) {
try {
final info = await session.find(contract.model.userId);
await flutterLocalNotificationsPlugin.show(
contract.model.time.millisecondsSinceEpoch,
info.name,
contract.model.text,
platformChannelSpecifics,
payload: payload);
} catch (e) {}
} else if (contract is NewNotify) {
try {
if (contract.model is CubeAnomaly) {}
await flutterLocalNotificationsPlugin.show(
contract.model.time.millisecondsSinceEpoch,
contract.model.id.toString(),
contract.model.time.toString(),
platformChannelSpecifics,
payload: payload);
} catch (e) {}
}
}