Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 推送通知:在本地化字符串中手动设置参数(当应用程序处于活动状态时)_Ios_Parse Platform_Push Notification_Apple Push Notifications - Fatal编程技术网

Ios 推送通知:在本地化字符串中手动设置参数(当应用程序处于活动状态时)

Ios 推送通知:在本地化字符串中手动设置参数(当应用程序处于活动状态时),ios,parse-platform,push-notification,apple-push-notifications,Ios,Parse Platform,Push Notification,Apple Push Notifications,当Parse.com在应用程序不在前台时发送推送通知时,一切正常。虽然找到了loc键可本地化字符串中的正确本地化字符串,并且通过loc args正确填写了参数: "%1$@ has created an event and sent out %2$@ invitations" 变成“Frank创建了一个活动并发出了14个邀请。” 变成“好消息:奥利弗加入了你的活动!” 当应用程序位于前台时,我也想显示应用程序内的横幅。为此,我需要获取与上面相同的正确字符串 func application(a

当Parse.com在应用程序不在前台时发送推送通知时,一切正常。虽然找到了
loc键
可本地化字符串中的正确本地化字符串,并且通过
loc args
正确填写了参数:

"%1$@ has created an event and sent out %2$@ invitations"
变成“Frank创建了一个活动并发出了14个邀请。”

变成“好消息:奥利弗加入了你的活动!”

当应用程序位于前台时,我也想显示应用程序内的横幅。为此,我需要获取与上面相同的正确字符串

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    let aps: NSDictionary! = userInfo["aps"] as! NSDictionary

    let alert: NSDictionary = aps.objectForKey("alert") as! NSDictionary

    let locArgs: NSArray = alert.objectForKey("loc-args") as! NSArray

    let locKey: String = alert.objectForKey("loc-key") as! String

    let localizedString: NSString = NSLocalizedString(locKey, comment: "")

    let localizedStringWithArgs = NSString(format: localizedString, locArgs)

    println(localizedStringWithArgs)
…如果locArgs是

( Frank,
"14"
)
输出为:

(
Frank,
14
) has created an event and sent out 14 invitations.
使用普通占位符时,如%@或

(
    Frank,
    14
) has created an event and sent out (null) invitations.
使用%1$@时,%2$@

…当应用程序处于非活动状态时,如何通过在正确的位置%1$@、%2$@…中填写loc参数,以与苹果相同的方式正确设置参数?

看一看有没有稍微有问题的解决方法看一看有没有稍微有问题的解决方法看一看有没有稍微有问题的解决方法
(
    Frank,
    14
) has created an event and sent out (null) invitations.