Background: I have in-app language change in my application and I also have number formatting that is based on locale. I have written an extension to NSLocale to handle this. My locale contains the in-app language. All this is working fine for me.
Issue: In few places (ex keyboard) locale is still read by platform from [NSLocale locale]. When device & in-app languages are different this is causing issues to me. I have tried to fix this by setting in-app language to user default. This works but only after I kill the app & restart it again. After restart [NSLocale locale] is returning correct values and keyboard behaves like I want.
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSString* lang = @"en_US";
[defaults setObject:@[lang] forKey:@"AppleLanguages"];
[defaults setObject:@[lang] forKey:@"NSLanguages"];
[defaults setObject:lang forKey:@"AppleLocale"];
Question1: Is there any legal way to kill/restart the app? Apple it self is doing this ex in language change or notification settings change. Is there any way for me to do this?
Question2: Would there be any other way fix my issue?