I'm wondering if there is any callback or another way to know that when device language is getting changed. I need to inform the remote server that user has changed their device language. I can't notice the change until I start the app again. I need to know the change in device language as soon as possible. The reason behind this is that until I inform the remote server about the language change I may get any push notification in the wrong language.
Asked
Active
Viewed 300 times
1
-
1Possible duplicate of [Forcing a language change notification iOS](https://stackoverflow.com/questions/17324589/forcing-a-language-change-notification-ios) – n00bProgrammer Sep 13 '17 at 11:39
-
1Not an exact duplicate, but what you're looking for is `NSCurrentLocaleDidChangeNotification`. Register for this on app launch. Also, check in both `didBecomeActive` and `didEnterForeground` for `locale` changes. – n00bProgrammer Sep 13 '17 at 11:42
-
use with the help of `NSCurrentLocaleDidChangeNotification` – Anbu.Karthik Sep 13 '17 at 11:43
-
When we change the device language iOS removes all the apps from memory and it restarts. So will I get informed after restart? – Shubham Sep 13 '17 at 11:47
1 Answers
3
When the device language is changed, all apps are killed. So a simple way to check for a language change would be to store the current language code in UserDefaults
inapplicationDidEnterBackground(:)
, and then check that value against the current language code in application(:didFinishLaunchingWithOptions:)

Ashley Mills
- 50,474
- 16
- 129
- 160
-
@Shubham You won't be able to know about a language change until your app is restarted. There's nothing you can do about that. I'd say it's a real edge case though - how many people actually change their device language (apart from devs when testing)? – Ashley Mills Sep 13 '17 at 12:05
-
Thanks for the information. And you are right about this case, in general, we rarely change the device language. – Shubham Sep 13 '17 at 12:12