How to show Arabic text in notification? [closed]

若如初见. 提交于 2019-12-13 04:17:20

问题


I am getting FCM push notification in both languages English/Arabic but I want to show it only in Arabic, How to show this?

My Code-

@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])
}

I am getting this notification in English(Match Reminder). How to set this in Arabic

My notification data is -

[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]

回答1:


You need to write a notification service extension. That will allow you to modify the notification's payload prior to display.

As the docs say:

A UNNotificationServiceExtension object ... lets you customize the content of a remote notification before it is delivered to the user.

And that is exactly what you are wishing to do.



来源:https://stackoverflow.com/questions/50857591/how-to-show-arabic-text-in-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!