I want to save two passwords (one app pin and one backend pin) in my keychain and am wondering how this should work.
I am using the KeychainItemWrapper with to different identifiers.
KeychainItemWrapper *kcw1 = [[KeychainItemWrapper alloc] initWithIdentifier:id1 accessGroup:nil];
KeychainItemWrapper *kcw2 = [[KeychainItemWrapper alloc] initWithIdentifier:id2 accessGroup:nil];
and I am using either one to save and retrive the app or the backend pin.
I use :
[self.kcw1 setObject:aVerifyCode forKey:(__bridge id) kSecValueData]
[self.kcw2 setObject:aAppPin forKey:(__bridge id) kSecValueData]
But it doesn't work - result is -25299 - The specified item already exists in the keychain
So how can I save multiple passwords in my keychain?
Okay I think I know what the problem is!
KeychainItemWrapper uses the identifier for the kSecAttrGeneric.
But this is not the one to distinguish entries. If you want to save two accounts or two passwords in
kSecValueData
this will result in an arror (-25299) for duplicate entires.
The reason is, that the apple keychain api uses
kSecAttrAccount
and
kSecAttrService
to distinguish entries.
So you can modify the keychainItemWraper if you want like shown in this thread
Related
I have two apps, (AppA and AppB). I want to save data in AppA and access it in AppB using App Group:
Code in App A:
- (IBAction)btnSetValuePressed:(id)sender {
NSUserDefaults *myDefaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.com.tcompany.testName"];
[myDefaults setObject:#"foo" forKey:#"bar"];
[myDefaults synchronize];
}
Code in App B:
NSUserDefaults *myDefaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.com.tcompany.testName"];
NSString *myString = [myDefaults objectForKey:#"bar"];
self.lblResult.text = myString;
Problem:
Is It secured enough?
It is secure in the sense that only the apps with access to that app group can see that data.
Each app has a sandbox and only that app may access its content. Let's call these apps, "app A" and "app B", there are therefore two sandboxes, sandboxA and sandboxB
When you define an app group you effectively create a third sandbox that is shared between your apps, let's call it sandboxC
Only those two apps can see that shared data, so in this expanded sense both apps as a pair have a secure private area for data.
App A can see sandboxA but not sandboxB
App B can see sandboxB but not sandboxA
Both app A and B can read and write to SandboxC
Note that both apps run in different processes so it could be possible for App A to be writing data to sandbox C at the same time that app B is reading from the same stored data item, for this reason care must be exercised to avoid possible conflicts.
If you use NSUserDefaults as the storage medium you are going to be safe because Apple ensure that NSUserDefaults behaves correctly in these concurrent circumstances.
I want to know that is it possible in iOS that one could get list of installed applications uploaded by same company?? If yes, then what would be the code???
I know that it's restricted to get list of installed apps in iOS. But I want to know that which of my applications are installed on user's device? So, does Apple allows to get list of own installed apps??
If you did some planning in advance and gave each app it's own URL scheme then you could check if each scheme in turn was openable by the app and count the number that were. But if your apps don't have defined schemes then no, you can't.
Well for the Second part of your question. Yes you can get the list of apps installed in your device using
-(void) allInstalledApp
{
NSDictionary *cacheDict;
NSDictionary *user;
static NSString *const cacheFileName = #"com.apple.mobile.installation.plist";
NSString *relativeCachePath = [[#"Library" stringByAppendingPathComponent: #"Caches"] stringByAppendingPathComponent: cacheFileName];
NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent: #"../.."] stringByAppendingPathComponent: relativeCachePath];
cacheDict = [NSDictionary dictionaryWithContentsOfFile: path];
user = [cacheDict objectForKey: #"User"];
NSDictionary *systemApp=[cacheDict objectForKey:#"System"];
}
The systemApp Dictionary contains the list of all system related app and user Dictionary contains other app information.
According to your First part of the question , you cannot directly get the list of apps for a particular company . But You could show a constant URL of the Apple store site to the user in a UIWebView or outside the app in Safari . This URL would have the list of all the apps. Also if you have the list of the URL's your app's loaded on the Apple store . then you could show them individually in the browser too.
no, nothing You ask is possible, of technical and local reasons.
You can see some details only on YOUR devices you configured with IPCU or similar tools, (MDMs..) but not in code.
In My Application I want show all my iPhone apps from itunes store in a tableview. If user clicks any one of cell it leads to take to appstore of that application.I know just statically by giving link of each application. As per my need i need to get new apps also after this installation.
You can use the search web service provided by Apple: http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html#searching
I couldn't find a way to search by artist ID for software, but you can still perform a generic query using the developer name.
For example, this would return apps by Gameloft:
http://itunes.apple.com/search?term=Gameloft&media=software&lang=en_US&country=us
Note that it's a query by name,so you can have false positives (apps where the name Gameloft appears but are not real Gameloft apps). You have to check the artistId property for each returned app (in this case, Gameloft's artistId is 282764297).
If you want to open the App Store to a specific app, use the trackId you got from the previous web service and then
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:
[NSString stringWithFormat:
#"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",
trackId]]];
Instead of doing your own table view, you can also use StoreKit to display the apps, and let the user purchase other apps right there.
Just replace 383916386 with the correct id for your developer account.
SKStoreProductViewController *viewCtrl = [[SKStoreProductViewController alloc] init];
[viewCtrl loadProductWithParameters:#{SKStoreProductParameterITunesItemIdentifier: #"383916386"} completionBlock:nil];
[self presentViewController:viewCtrl animated:YES completion:nil];
Hello
I have an app with a textfield that user have to enter his email.
Is there any way to cache the emails that have been inserted to this textfield?
I want an autocomplete of the email when the user enter the email. If this is not possible I want at least the app save the last email that the user has used. How to do that?
Use this to store the email value:
[[NSUserDefaults standarduserdefaults] setValue:#"user#domain.com" forKey:#"Email"];
To Read it back use:
NSString *sEmail = [[NSUserDefaults standarduserdefaults] stringForKey:#"Email"];
You could save the data by using NSUserDefaults - save it when the user has finished entering the e-mail address, then restore it again when the view is loaded.
If you want to store large number of emails means you have to use the property list... In NSUserDefaults you have to store only the important values
Property list
so I got my iPhone app to use the keyChain and store my password.
KeychainItemWrapper *kc = [[KeychainItemWrapper alloc] initWithIdentifier:#"Password"];
[kc SetObject:#"My_Password" forKey:(id)kSecAttrAccessGroup];
[kc release];
This saves my password correctly.
I tried to pass a string (username) instead of (id)kSecAttrAccessGroup to relate the password to a specific username, but It crashes.
QUESTION: How can i relate the stored password to a username, because my app allows multipple user to login.
I know it's not really an answer to your quesiton. But I use SFHFKeychainUtils(Github).
It's also a wrapper and it allows you exactly what you are looking for. Store a password associated to a username. Here's some code how I did it with SFHFKeychainUtils.
NSString *username = #"Username";
NSString *password = #"Password";
[SFHFKeychainUtils storeUsername:username andPassword:password forServiceName:#"Your App" updateExisting:YES error:NULL];
Or pass an pointer to a NSError object if you want any error information. ;-)
I hope my answer will help you...
Sandro Meier