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:
- UIWebView could execute JavaScript by stringByEvaluatingJavaScriptFromString.
- write a function in a page with JavaScript, which responds to an event on the page (button click, etc.), then change the state.
- 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.
精彩评论