3

I'm trying to send iOS push notifications from Amazon SNS and i'm able to do it, but i want to use localized formatted string to send the notification and push the message in the right language.

I'm using XCode 7.0.1 and developing with an iPhone 5S, but i think that's not the point.

So this is the message i'm trying to send:

{  
   "default":"This is the default Message",
   "APNS_SANDBOX":"{ "aps" : {  "alert" : {
        "loc-key" : "GAME_PLAY_REQUEST_FORMAT",
        "loc-args" : [ "Jenna", "Frank"]
    },"data": { "type": "dashboard", "opponentName":"Juan ","gameCategory":"Multimedia","gameType":"combo","ugid":"123456789" }, "badge" : 9,"sound" :"default"}}"
}

It can be send, but its not changed in the device and the message is "GAME_PLAY_REQUEST_FORMAT", so what i want to be displayed is the value of this key in my Localizable.strings file:

"GAME_PLAY_REQUEST_FORMAT" = "%@ and %@ have invited you to play";

I've red that you can do it in the apple's documentation (https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW21)

Hope anyone can help.

Thanks

Norolim
  • 926
  • 2
  • 10
  • 25

1 Answers1

1

I'll post the answer here so everyone can see it.

@TàTruhoada yes, you need to use loc-keys in the payload. You can see how it works in the following link: Creating the Remote Notification Payload

Use loc-key to pass a key that is defined in your application's Localizable.strings file. The iPhone looks up the key and replaces it with the string found for the current localization. You can see more information in this link from Erica Sadun: Building Notification Payloads

Norolim
  • 926
  • 2
  • 10
  • 25