开发者

How to invoke local peripheral device from web script

I am confused about invoking local app from web site. Is there any way to start an ipad/iphone app from web scripts? I remember that there is ActiveX with IE开发者_如何学JAVA which could start a local device such as a camera or printer. JavaScript could invoke ActiveX. But there is no activeX in iOS. Here is my problem: How could I start local device from a webpage? Does anyone have the same problem? I have one method but I don't know if it is feasible:

  1. UIWebView could execute JavaScript by stringByEvaluatingJavaScriptFromString.
  2. write a function in a page with JavaScript, which responds to an event on the page (button click, etc.), then change the state.
  3. start a thread to inquire the state. When the state changes , invoke local apps.

Is that possible or any better way ?


If you wish to open your app from Safari browser from you iPad then there is a method to do so. Add the following tags in your app's info.plist file:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.companyname.appname</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>openApp</string>
        </array>
    </dict>
</array>

Save the plist file and now on the web page put openApp:// in place of the link when user clicks the desired button. This won't be helpful if you try to implement it in your own app in a web view. But it will work from Safari browser from your iPad or from any other app.

I hope this is helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜