I have a completionHandler of type UNNotificationPresentationOptions, Now I want to return string value, instead of .alert.
I want to show Arabic text in my notification, So I want to set msg value in completionHandler
@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
print(userInfo)
let userInfoa = notification.request.content
let sd = userInfoa.title
if let jsonResult = userInfo as? Dictionary<String, AnyObject> {
var msg = ""
if let aps_Data = userInfo as? Dictionary<String, AnyObject> {
if let ar_message = aps_Data["gcm.notification.body_ar"] {
print(ar_message)
msg = ar_message as! String
}
}
let content:UNNotificationPresentationOptions = msg
completionHandler([content])
//completionHandler([.alert]) . *I dont want use .alert
}
}
}
