0

I am developing two apps and I want to access from one app to another.

My idea is to work in the app A, and when I click a button, open app B, select a photo of this app and go back again to app A. The behavior that I want to reproduce is quite similar to the behavior of the photo camera.

How can I do that? I have tried using: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];

but with this function I lose the control of the app, I cannot go back with the image or I don't know how to do it

thanks for your help

Devper
  • 11
  • 1

1 Answers1

0

You can open App B using a custom URL scheme (as you are currently doing):

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURLForAppB]];

Select the image and save it to the pasteboard (or you could upload to a server, but that is more complicated, time consuming, data intensive...):

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[[UIPasteboard generalPasteboard] setImage:myImage];

Open App A again using another custom URL scheme:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURLForAppA]];

Extract the image from the pasteboard:

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
UIImage *myImage = pasteboard.image;
Spaceship09
  • 341
  • 3
  • 8
  • 1
    Never hijack the users pasteboard - users can have valuable data in there! Instead use some kind of scheme to transfer. In iOS 8 there are app groups that allows different apps to have access to the same containers. Way better solution! http://stackoverflow.com/questions/24387871/share-datas-between-two-apps-with-ios-8-app-groups-using-nsuserdefaults http://stackoverflow.com/questions/24015506/communicating-and-persisting-data-between-apps-with-app-groups/24063144#24063144 – Trenskow Feb 12 '15 at 12:03