iOS application only show Emoji & English keyboards - ios

iOS application written in Objective-C only show English & Emoji keyboards.
All other application are working normally and other keyboards (ex: Polish, Hebrew) are available to use.
I tried to look for .plist restrictions or something i did in the development process. didn't find anything.
appreciate your help.

Well, i found the problem.
In my main.m file i had this two rows that prevent my system from allowing any other keyboard then english:
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:#"en_EN", nil] forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize]; //to make the change immediate
To overwrite this code for users who already installed the applkaction - i have changed it to:
if ([[NSUserDefaults standardUserDefaults]valueForKey:#"AppleLanguages"]){
[[NSUserDefaults standardUserDefaults] removeObjectForKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize]; //to make the change immediate
}
Now everything is working as expected.

Related

Change global language in ios app

I want to change the main language just for my app (not the whole phone). When the user selects spanish in the settings menu the whole app should from now be in spanish. I searched a lot and found everytime that the solution is to override the AppleLanguages key in NSUserDefaults. So I made this:
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:#"es", #"de", #"en", #"ru", #"it", nil] forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
When I restart the app I do a log in the AppDelegate and the AppleLanguages is set to the default order (Spanish not the first language what it should be) and the global app language is set to default. Is this the right way?

Is there a way to change the locale/language on an iOS Simulator through code?

I was searching for a way to change the iOS device Locale without having to go through the settings and importing some new framework. Just a simple script or so would be great, or even a piece of code. I was wondering if there was something like :
[[NSLocale currentLocale] setLocale:#"WhateverLocale"];
This may or may not fulfill your needs, but one way to gain programmatic access over the app's current locale is to override the AppleLanguages key in NSUserDefaults. For example, to change to French:
[[NSUserDefaults standardUserDefaults] setObject:#[ #"fr" ]
forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
The downside to this approach is that you need to close and reopen the app for the change to take effect.
Note, to return to the system default, simply call:
[[NSUserDefaults standardUserDefaults] removeObjectForKey:#"AppleLanguages"];

Best User Login implementation iOS

I am a web developer that has recently moved over to iOS dev. I have implemented a login system for my website and I want to integrate this same functionality within my app. I will have login UI in the app that communicates with the web server using the AFNetworking library to make POST requests.
However, I am not sure how I will deal with remembering things in regard to user logins such as whether the user was logged in previously? With Web, I would do cookies and sessions, but I am not sure whether this is the best approach with iOS. I've also read about some people talking about storing things within the iOS keychain for security reasons. Can anyone shine some light on what the best practise for achieving what I want would be?
Thanks!
I would use NSUserDefaults but I think you should use token-based approach for your iOS client. When ever you log in and get a successful response, you should store your token in user defaults with the following code.
[[NSUserDefaults standardUserDefaults] setValue:token forKey:#"auth_token"];
[[NSUserDefaults standardUserDefaults] synchronize];
Your logout function could look something like this.
- (void)logout {
[[NSUserDefaults standardUserDefaults] setValue:nil forKey:#"auth_token"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
You can send this auth_token each time you make a web request so that the server knows those requests are authorized.
In objective-C there is the NSUserDefaults that can be used similarly.
To save a bool value for example you would do the following
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"IsLoggedIn"];
[[NSUserDefaults standardUserDefaults] synchronize];
to later load the value you write
BOOL isLoggedIn = [[NSUserDefaults standardUserDefaults] boolForKey:#"IsLoggedIn"];
Hope it helps!

Delete keychain data on iOS

I have an iOS application that uses the keychain to store some information related to the authentication. I would like to remove this data from the keychain when the application is uninstalled.
How can I get aware of the application being uninstalled/removed?
You canĀ“t detect when your application is going to be deleted from your device. But you could detect when your app is launched for first time, after to be installed. For this I use the next code:
if (![[NSUserDefaults standardUserDefaults] boolForKey:#"HasLaunched"])
{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"HasLaunched"];
[[NSUserDefaults standardUserDefaults] synchronize];
//Here delete your info kept in your keychain. If not exist will not delete nothing, but if it exist mean your app has been installed again.
[removeYourPropertyInKeychain];
}

Settings.bundle: how should application recognize the fact that a value got changed outside of app? [duplicate]

This question already has answers here:
How to determine when Settings change on iOS
(7 answers)
How to receive NSUserDefaultsDidChangeNotification iphone
(1 answer)
Closed 9 years ago.
I am using Settings bundle to configure my app. As a side effect, the same set of settings is available outside the app in iOS Settings. This is great. However there is a little problem - I do need to react to the changes. For example, I have a name that a user is using to be recognized by others and if it changes, a server call must happen. How to handle that?
EDIT: take it easy, fellas. I've never done that before and it's hard to read thru all guidelines available. Settings.bundle is not an obvious thing to deal with. Anyways, feel free to vote the question down but at least take a minute and read thru all commends before you do so.
Tried a couple suggested ways, i.e. using notifications and in more direct manipulation of defaults when app becomes active. The second approach worked better because it only executed at times I expect instead of every time any config setting is changed/added/deleted within the app.
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSString *nameOld = [[NSUserDefaults standardUserDefaults] stringForKey:kNameKey];
[[NSUserDefaults standardUserDefaults] synchronize];
NSString *nameNew = [[NSUserDefaults standardUserDefaults] stringForKey:kNameKey];
You should check for changes to settings in this appDelegate method.
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Check for any changes to settings
[[NSUserDefaults standardUserDefaults] synchronize];
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
bool userICloudChoice = [userDefaults boolForKey:_cloudPreferenceKey];
}

Resources