1

When Parse.com is sending push notifications while the app is not in the foreground, everything works just fine. Though the loc-key the correct localized string from localizable.string is found and the arguments that come through loc-args are filled in properly:

"%1$@ has created an event and sent out %2$@ invitations"

becomes "Frank has created an event and sent out 14 invitations."

"Good News: %1$@ has joined your event!"

becomes "Good News: Oliver has joined your event!"

when the app is in the foreground, I want to show an in-app banner as well. For that purpose I need the get the same correct string as above.

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)

...if locArgs is

( Frank,
"14"
)

the output is:

(
Frank,
14
) has created an event and sent out 14 invitations.

when using normal placeholder like %@ or

(
    Frank,
    14
) has created an event and sent out (null) invitations.

when using %1$@, %2$@...

...how can I properly set the arguments in the same way it is done by apple when the app is inactive through filling in the loc-args in the right spots %1$@, %2$@...?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.