What if app bundle does not contain a key for the "loc-key" received in push notification?
Asked Answered
A

3

8

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)?

Autecology answered 17/4, 2013 at 9:58 Comment(0)
I
3

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.

Iqbal answered 17/4, 2013 at 10:1 Comment(5)
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. thanksAutecology
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
T
1

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.

Tibbitts answered 6/9, 2017 at 13:35 Comment(0)
A
0

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!

Arnone answered 8/9, 2022 at 12:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.