Stavros_S
Stavros_S

Reputation: 2235

iOS notification localization failing with FCM (Firebase Cloud Messaging)

I'm using FCM to send localized notifications to both Android and iOS. The flow works and both platforms receive the notification, but on iOS if I try to send a localized key along with arguments the localization fails. If I send a resourceKey with out the need for args it works fine.

Sample payload request

curl -X POST --header "Authorization:key=AAAAR*************aHT" --Header "Content-Type:application/json" https://fcm.googleapis.com/fcm/send -d "{  
   "notification":{  
      "title_loc_key":"titleResourceKey",
      "body_loc_key":"bodyResourceKey",
      "body_loc_args": ["test", "test"]
      "badge":"1",
      "sound":"default"
   },
   "priority":"High",
   "to":   "dqIeO*****relj3k}"

The values in the iOS localizable.strings file.

"titleResourceKey"="title string";
"bodyResourceKey"="s% s% has passed.";

The Values in the android strings.xml file.

  <string formatted="false" name="titleResourceKey">"title string"</string>
  <string formatted="false" name="bodyResourceKey">"s% s% has passed."</string>

Upvotes: 2

Views: 1837

Answers (1)

Stavros_S
Stavros_S

Reputation: 2235

The issue here ended up being caused by the localization plugin I was using in the Framework used to build the application (Nativescript). The strings containing %s needed to be %@ in iOS.

Upvotes: 1

Related Questions