local_notifications
local_notifications copied to clipboard
App would crash if send push notification from server
Since notification from server didn't have PRESENT_WHILE_APP_OPEN_KEY column
public func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent: UNNotification,
withCompletionHandler: @escaping (UNNotificationPresentationOptions)->()) {
let showNotificationWhileAppOpen = willPresent.request.content.userInfo[SwiftLocalNotificationsPlugin.PRESENT_WHILE_APP_OPEN_KEY] as! Bool
if (showNotificationWhileAppOpen) {
withCompletionHandler([.alert, .sound, .badge])
}
}
I have not had much free time recently, so I haven't been able to get around to this. I'd suggest checking out flutter_local_notifications, see if that plugin supports this functionality, if you need this right away.