如何在通知中显示阿拉伯文字?
How to show Arabic text in notification?
我收到两种语言的 FCM 推送通知English/Arabic,但我只想用阿拉伯语显示,如何显示?
我的代码-
@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
if let jsonResult = userInfo as? Dictionary<String, AnyObject> {
if let notifyType = jsonResult["type"] as? String {
if notifyType == "8" || notifyType == "18" {
self.pushRedirection(userInfo: userInfo)
}else{
if let league_id = jsonResult["league_id"] as? String {
if let contestUnique_id = jsonResult["contest_unique_id"] as? String {
}
}
}
}
}
completionHandler([.alert,.sound])
}
我收到的是英文通知(比赛提醒)。如何用阿拉伯语设置
我的通知数据是-
[AnyHashable("gcm.notification.type"): 5, AnyHashable("league_id"): 3, AnyHashable("en_msg"): Match Reminder, AnyHashable("gcm.notification.ar_msg"): القوانين, AnyHashable("gcm.notification.en_msg"): Match Reminder, AnyHashable("gcm.notification.league_id"): 3, AnyHashable("contest_unique_id"): KBm8oVuTR, AnyHashable("gcm.message_id"): 0:1528974245362555%6c5fd9d06c5fd9d0, AnyHashable("gcm.notification.contest_unique_id"): KBm8oVuTR, AnyHashable("ar_msg"): القوانين, AnyHashable("google.c.a.e"): 1, AnyHashable("type"): 5, AnyHashable("aps"): {
alert = "Match Reminder";
}, AnyHashable("body"): Match Reminder]
你需要写一个notification service extension。这将允许您在显示之前修改通知的有效负载。
正如 docs 所说:
A UNNotificationServiceExtension object ... lets you customize the content of a remote notification before it is delivered to the user.
而这正是您想要做的。
我收到两种语言的 FCM 推送通知English/Arabic,但我只想用阿拉伯语显示,如何显示?
我的代码-
@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
if let jsonResult = userInfo as? Dictionary<String, AnyObject> {
if let notifyType = jsonResult["type"] as? String {
if notifyType == "8" || notifyType == "18" {
self.pushRedirection(userInfo: userInfo)
}else{
if let league_id = jsonResult["league_id"] as? String {
if let contestUnique_id = jsonResult["contest_unique_id"] as? String {
}
}
}
}
}
completionHandler([.alert,.sound])
}
我收到的是英文通知(比赛提醒)。如何用阿拉伯语设置
我的通知数据是-
[AnyHashable("gcm.notification.type"): 5, AnyHashable("league_id"): 3, AnyHashable("en_msg"): Match Reminder, AnyHashable("gcm.notification.ar_msg"): القوانين, AnyHashable("gcm.notification.en_msg"): Match Reminder, AnyHashable("gcm.notification.league_id"): 3, AnyHashable("contest_unique_id"): KBm8oVuTR, AnyHashable("gcm.message_id"): 0:1528974245362555%6c5fd9d06c5fd9d0, AnyHashable("gcm.notification.contest_unique_id"): KBm8oVuTR, AnyHashable("ar_msg"): القوانين, AnyHashable("google.c.a.e"): 1, AnyHashable("type"): 5, AnyHashable("aps"): {
alert = "Match Reminder";
}, AnyHashable("body"): Match Reminder]
你需要写一个notification service extension。这将允许您在显示之前修改通知的有效负载。
正如 docs 所说:
A UNNotificationServiceExtension object ... lets you customize the content of a remote notification before it is delivered to the user.
而这正是您想要做的。