Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

c# - Open iOS application from Unity

I'm wanting to open up another application on my ipad via a button press in Unity. I know normally I would use Application.OpenURL() on my button press, but I'm unsure as to what to put in the brackets. This is an application already on the iPad and isn't one I've created.

Has anyone ever done this before? Could you possibly point me in the right direction so I can get this to work? Is it even possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The other application needs to support that behaviour, by defining a custom url scheme. The developer needs add an URL Type i.e. "awesomeapp" in Xcode under Targets > Info > URL Types, if he does not support it you can not open the app.

In your Unity app just call

Application.OpenURL("awesomeapp://").

see also this stackoverflow entry: Launch an app from within another (iPhone)

UPDATE 1: how to find a custom URL scheme of 3rd party app

  1. Download the purchased app via iTunes on OSX
  2. Go to the [AppName].ipa file on your filesystem
  3. Rename it to a [AppName].zip so that you can extract it
  4. Go to "[AppName]/Payload/[AppName].app"
  5. Right click and select "Show Package Contents"
  6. Open the Info.plist in Xcode and look for the key URL types or in a text editor for CFBundleURLTypes.

UPDATE 2: iOS 9

For iOS 9 you must whitelist that application in the Info.plist of the Xcode Project:

<key>LSApplicationQueriesSchemes</key>
<array>
     <string>awesomeapp</string>
</array>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...