如何在通知中显示阿拉伯文字? [英] How to show Arabic text in notification?

查看:81
本文介绍了如何在通知中显示阿拉伯文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了英语/阿拉伯语两种语言的 FCM 推送通知,但我只想用阿拉伯语显示,如何显示?

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

我的代码-

@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

我的通知数据是 -

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

推荐答案

你需要写一个通知服务扩展.这将允许您在显示之前修改通知的有效负载.

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

正如文档所说:

UNNotificationServiceExtension 对象...让您可以在将远程通知传送给用户之前自定义其内容.

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

这正是您想要做的.

这篇关于如何在通知中显示阿拉伯文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆