Ios 推送通知:在本地化字符串中手动设置参数(当应用程序处于活动状态时)
当Parse.com在应用程序不在前台时发送推送通知时,一切正常。虽然找到了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
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.