Reputation: 472
I would like to communicate between two Apps installed on the same phone. In order to do this, I read many official documents to understand that I have to implement a Custom URL Scheme.
Before iOS 9, it seems that we have to add a URLType in Info and define the URL Scheme : " ".
But after the iOS 9, it change the way to communicate between Apps.
The url scheme example is discussed in: Querying URL Schemes with canOpenURL.
My App A code below:
@IBAction func sender(sender: AnyObject) {
let ourapplication : UIApplication = UIApplication.sharedApplication()
let ourpath : String = "iOSTest://"
//.stringByAppendingString(urlEncodedText)
let oururl : NSURL = NSURL(string: ourpath)!
ourapplication.canOpenURL(oururl)
}
At My App B, I add a url name iOSTest in Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>iOSTest</string>
</array>
When I install the two App on my iPhone to test, it doesn't work at all.
Here is my error!
What's wrong with my App?
Upvotes: 2
Views: 412
Reputation: 318774
You have it setup incorrectly. The app calling canOpenURL
is the app that needs to add the custom scheme to the LSApplicationQueriesSchemes
list.
Since App A is calling canOpenURL
for iIOSTest
, it is App A that needs to add iOSTest
to the LSApplicationQueriesSchemes
list, not App B.
App B would be the app that needs to register that it responds to iOSTest
so that it will be opened when some other app calls openURL
with a scheme of iOSTest
.
Upvotes: 3