According to apple documentation, notification payload can carry "loc-key" key which identifies localization string key in app bundle. What will happen if there will be no such key in app's bundle (for instance, when there were updates on the server and new notification types were added)?
What if app bundle does not contain a key for the "loc-key" received in push notification?
Asked Answered
You will most likely get the default behaviour of NSBundle
's localizedStringForKey:value:table:
method which is to return the key when the value can not be found.
is there a way to setup a key that is returned "by default"? –
Autecology
@Autecology the default is the name of the key (the value of
"loc-key"
). –
Subversive it seems like it should work like that. so, i need to track app version on the server-side in order to push appropriate loc-keys to the client. thanks –
Autecology
Did anyone find out the real answer? There's no way to fallback to a "default" key if any key does not exist? –
Seely
I just tested it, Mike's answer is correct, the key itself is returned when the value cannot be found. –
Twin
You can send your message template in loc-key: "%1$@ won the game" with "John" in loc-args will become "John won the game", though you app doesn't have "%1$@ won the game" in Localizable.strings.
WRONG!
Actually, if you provide a body
string it will fall back to that. Only if you do not provide a non-localized string it will show the key as text!
© 2022 - 2024 — McMap. All rights reserved.