Okan Kocyigit
Okan Kocyigit

Reputation: 13421

How to localize iOS notifications by app language

I'm using the pod Localize which is a language switch tool.

My app has a preferences menu where users can change app language from the list.

When user changes the language I'm also setting the AppleLanguages key in UserDefaults

Localize.setCurrentLanguage("nl")
UserDefaults.standard.set(["nl"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()

This is working properly for my app, everything is good except notification localization.

I've read the apple documentation about the localization local and remote notifications.

I'm storing localized content in my app, sending notification with loc-key and loc-args.

But notifications are always received in the user's preferredlanguage which is set by iphone preferences and might be different with my app language.

How can I solve this problem and localize notifications by app specific language?

Upvotes: 3

Views: 1867

Answers (1)

Krishna Datt Shukla
Krishna Datt Shukla

Reputation: 997

Yes, user will always get the notification in user's preferredlanguage which is set by iPhone preferences because Apple never recommend changing language from the app itself. If you do it then you will need to localize the notification content on your server and before sending push to any user, you will need to check the language of your app that user is using in. And then send notification in the application selected language. No matters what language is selected in device settings.

Hope it helps. If you have any confusion, feel free to comment.

Upvotes: 3

Related Questions