Moving data / images between two iOS apps using a custom URL handler

After searching and searching SO for a while, I could not find the answer -

I wondered: how could I transfer data between my two applications using custom URL handlers? In particular, an image or an NSData object, for that matter.

I know that I can open certain parts of my application using custom handlers such as myapp1: // start, myapp2: // start, but I'm not sure how to proceed with transferring large amounts of data (~ 80k) through these handlers.

I would like to hear any creative decisions :)

ps The solution must be iOS> = 4.3 Compatible

+7
source share
5 answers

Use custom URL handlers in conjunction with a UIP card. Save something from your first application (say, an image) into a common cardboard, for example:

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

Then use custom URL schemes to switch applications.

Then extract your image from the new application when you need it:

  UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; UIImage *tempImg = pasteboard.image; 

Battle trials .; )

+9
source

One solution could be:

  • Web server deployment
  • Open the second application using a custom URL scheme with the IP address and port of your custom web server included in the URL
  • Add a route or parameters to your image also in your URL.

Download and enjoy your photo :-)

Another solution:

  • Launch the Bonjour service.
  • on the network, a second application can find this service
  • do the magic of transferring data between applications

EDIT: BEST OTHER SOLUTION:

Just found another, but much more efficient way to share large data sets:
It is called UIPasteboard

Best link for this:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPasteboard_Class/Reference.html

And one more resource:
http://kmithi.blogspot.in/2012/03/sharing-data-among-ios-applications.html

That should do it. For a web server: there are many implementations found with Google

+3
source
  [http://www.codeproject.com/Articles/43447/How-to-Use-UIPasteBoard-to-Implement-Custom-Copy-a][1] As you know many of the controls in UIKit now come pre-loaded with the ability to copy and paste text. You can also use this new ability in your own apps to copy and paste other things including: images, SQLite databases, text or any file. This is a great way to share data between your apps if you want to provide users with a suite of apps with integrated functionality. CopyFrom Source Code -(IBAction)copyImageToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; appPasteBoard.persistent = YES; NSData *data = UIImagePNGRepresentation([UIImage imageNamed:@"Old-Time-Photo.jpg"]); [appPasteBoard setData:data forPasteboardType:@"com.appshop.copyfrom.imagedata"]; } -(IBAction)copyStringToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; appPasteBoard.persistent = YES; [appPasteBoard setString:textView.text]; } PasteTo Source Code -(IBAction)pasteImageToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; NSData *data = [appPasteBoard dataForPasteboardType:@"com.appshop.copyfrom.imagedata"]; imageView.image = [UIImage imageWithData:data]; } -(IBAction)pasteStringToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; textView.text = [appPasteBoard string]; } Using UIPasteBoard in iPhone programming is amazingly simple and opens up some possibilities that we did not have a year ago. To use UIPasteBoard you simply create a instance using pasteboardWithName, put stuff into the paste board and then set the persistant property equal to YES. Then any app can get a reference to your paste board and use the data contained within. You can use it for simple strings and even data that you can put into NSData like SQLite databases. 
+1
source

using a custom URL handler

it is specified, so it will not meet your specification.

But if this does not bother you, I would write an 80k image to the internal memory (file system), even if it were 80Mb, and pass "url" to another application.

Great ego and research effort:

copy to image folder

IPC Communication via URL

and my solution doesn’t work ... I don’t give fish, just learning how to get fish hot.

0
source

Well, as far as I can tell, ~ 80k is too much for a custom URL handler. But you can try Base64 to encode your data and add it to your custom URL. But I doubt that it will work with a lot of data.

You can also look at the UIDocumentInteractionController , which is designed to open files with other applications that support them. This is what the Mail application does when you open an attachment with another application.

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html#//apple_ref/doc/uid/TP40009304

0
source

All Articles