I am working on a app on watch app. The app version is watch 2.0 and i'm using the xcode 7.3.1. and the swift version is 2 which i have used in my code.
Now the problem is i want to show an alert according to the current language that is selected in the user's watch. But i'm not able to get the current language of watch. It always return the en_us. I have checked the many post's but no one solution worked for me.
So now i have decided to show the alert according to the region of user. I have check the code on iphone its working properly but i dont know that if watchkit is able to detect the current region of user.The code that i have used to check the current region is :
let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String
If anyone have any idea about it then please suggest me. Thanks in advance.
Get the current region of user on watchkit 2.0
nr: #1 dodano: 2017-09-25 12:09
You should be using let userLanguage = Locale.preferredLanguages.first to get the language currently used by the user. This API is available from watchOS2, so that should be fine, but I couldn't test Swift 2, so the property names might be slightly different.