Reputation: 104065
I’ve got several iOS apps and I need them to be aware of each other. More precisely, I need to know whether there’s already one of my apps installed.
I thought about registering a custom URL scheme (something like my-app-present://
), so that I could check whether the custom scheme is supported and if yes, I would know there’s already one of my apps on the device. But that doesn’t work, because the schemes are registered through Info.plist
and the app registers the scheme before it has a chance to check for its existence. In other words, the check always succeeds.
Then I thought about creating a file in the temporary directory, but NSTemporaryDirectory()
returns a folder inside the application sandbox, so that wouldn’t work either. I also thought about keychain, but again it looks like each application has strictly separate keychain on iOS.
I don’t want to go through the list of running apps and I don’t want to use networking. Do you know some other tricks?
Upvotes: 0
Views: 4973
Reputation: 2942
If by "talk to each other" you meant you just want to detect whether other app has been installed or not then iHasApp is an open source iOS framework could come in handy. I haven't used it yet. but from the description it appears to be a good choice.
http://www.ihasapp.com/documentation/Classes/iHasApp.html
Upvotes: 0
Reputation: 118711
The custom URL scheme method sounds fine, as long as you have a different scheme for every app, for example my-app-1://
and my-app-2://
. Then (I assume this is what you already knew) you can use canOpenURL:
to check if the URL can be handled (i.e., your app is installed).
Upvotes: 2