locoboy
locoboy

Reputation: 38960

Is it possible to access data across 2 different iOS apps?

Let's say that I store some ID data in App1 and want to access it in App2 on the same device. Is this possible on the platform? Are there any workarounds for this if not?

Upvotes: 6

Views: 4242

Answers (3)

Amit
Amit

Reputation: 1795

Image Share Between My app to Instagram:

NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.ig"];

    NSData *imageData = UIImagePNGRepresentation(originalImageView.image);
    [imageData writeToFile:savedImagePath atomically:YES];        
    NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath];

    UIDocumentInteractionController * docController = [[UIDocumentInteractionController alloc] init];
    docController.delegate = self;
    [docController retain];
    docController.UTI = @"com.instagram.photo";
    [docController setURL:imageUrl];
    [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
} 

Upvotes: 2

John Estropia
John Estropia

Reputation: 17500

You can use the iOS keychain. Here's a good tutorial on keychain access groups.

Upvotes: 3

Peter Sarnowski
Peter Sarnowski

Reputation: 11970

One workaround is to register apps as handling some filetype. When such file is about to be opened, a user gets the choice of apps that can handle it and the chosen app gets a copy of the file copied to it's ~Documents/Inbox directory. But i think you're better with some external service.

Upvotes: 2

Related Questions