3

I have App A and App B. Here I just want to share text data from A to B and for that I doing following code.

In A :

UIApplication.sharedApplication().openURL(NSURL(string: "B://sample_text")!)

In B :

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
      print(url)
      return true
}

Output in B : B://sample_text

Using above code, I can able to send sample_text data from A to B. But App B is getting open that I don't want.

I want to share the same data and it should get in B when I launch B manually in future.

May be if there is any other method than openURL, then please suggest.

App Group can achieve this but it has limitation like you can only share data between applications that share a common app ID prefix.

Sunil Targe
  • 7,251
  • 5
  • 49
  • 80
  • Possible duplicate of [Sharing data in between apps in IOS](http://stackoverflow.com/questions/32652795/sharing-data-in-between-apps-in-ios) – Teja Nandamuri Aug 10 '16 at 16:49
  • @TejaNandamuri Not duplicate, because I have specifically mentioned that I want through URL Scheme and the link which you put here which has accepted answer with "App Group" concept that I already know before putting my question. But still thanks for you to communicate. :) – Sunil Targe Aug 10 '16 at 17:01
  • It is still a duplicate as that link is the only way to solve your question(And you didn't mention that you know about app group) .You cannot say that I will call openURL method, but it should not open. Of course URL scheme will call the openURL method and there is now way of stopping it. – Teja Nandamuri Aug 10 '16 at 17:05
  • may be you're right, so I edited my question. thnx – Sunil Targe Aug 10 '16 at 17:14

1 Answers1

3

You might want to check out App Groups to share data between your two apps instead of sharing data using a URL scheme.

An example can found at Sharing data in between apps in IOS.

The alternative is to store the data to, and read it from, a backend server.

Daniel Zhang
  • 5,778
  • 2
  • 23
  • 28
  • In App Group there are limitation like you can only share data between applications that share a common app ID prefix. So that I want through Custom URL Scheme. – Sunil Targe Aug 10 '16 at 17:04
  • Are you talking about performing the above task betwen your app and app developed by someone ? @SunilTarge – Teja Nandamuri Aug 10 '16 at 17:08
  • Both app developed by me but from different app ID. @Teja Nandamuri – Sunil Targe Aug 10 '16 at 17:16
  • @SunilTarge Are you sharing data between apps in different developer accounts? If not, why would the App ID prefix be an issue for you? – Daniel Zhang Aug 10 '16 at 17:35
  • @Daniel yeas, I'm sharing data(only string) between apps in different developer accounts. So just wanted to know is it possible to do through custom URL Scheme but it should be silently send to second app. – Sunil Targe Aug 11 '16 at 01:46
  • @SunilTarge Thanks for clarifying that. It doesn't seem like it will be possible at this time using a URL scheme without opening the other app. – Daniel Zhang Aug 11 '16 at 09:32