Created
November 5, 2012 09:32
-
-
Save netloner/4016319 to your computer and use it in GitHub Desktop.
PhoneGap 串接說明
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| <meta name="format-detection" content="telephone=no" /> | |
| <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> | |
| <link rel="stylesheet" type="text/css" href="css/index.css" /> | |
| <title>Hello World</title> | |
| </head> | |
| <body> | |
| <div class="app"> | |
| <h1>Apache Cordova</h1> | |
| <div id="deviceready" class="blink"> | |
| <p class="event listening">Connecting to Device</p> | |
| <p class="event received">Device is Ready</p> | |
| </div> | |
| <div> | |
| <br /> | |
| <p class="center"><a href="#" onclick="go();return false;">Get iOS Serial</a></p> | |
| <br /> | |
| <p class="center"><a href="#" onclick="logout();return false;">Go to iOS Start View</a></p> | |
| <br /> | |
| <div id="result_div" class="center" style="width:100%;"> | |
| </div> | |
| </div> | |
| </div> | |
| <script type="text/javascript" src="cordova-2.2.0.js"></script> | |
| <script type="text/javascript" src="js/index.js"></script> | |
| <script type="text/javascript"> | |
| app.initialize(); | |
| var successCallback = function(serial) { | |
| //Sample Result => serial = testToken_20121105170559_dac82b56ce668aebb684f8be8d5bb0f9 | |
| console.log("serial = " + serial ); | |
| document.getElementById("result_div").innerHTML = serial; | |
| }; | |
| var failCallback = function(err){ | |
| alert('Error: PhoneGap is failed to get iOS serial. No serial found on device.'); | |
| }; | |
| function go(){ | |
| //PhoneGap 語法,代表要 Call 我 iOS 當中的 QuickBid Plugin,並呼叫該 Plugin 裡面 Native 的 getSerial 函數。 | |
| cordova.exec( successCallback, | |
| failCallback, | |
| "QuickBid", | |
| "getSerial", | |
| [ ] | |
| ); | |
| } | |
| function logout(){ | |
| // Make sure the user is logout from QuickBid, and then call this js function. | |
| //PhoneGap 語法,代表要 Call 我 iOS 當中的 QuickBid Plugin,並呼叫該 Plugin 裡面 Native 的 logout 函數。 | |
| cordova.exec( function(){ console.log('Successfully logout.')}, | |
| function(){ console.log('Logout Fail.')}, | |
| "QuickBid", | |
| "logout", | |
| [ ] | |
| ); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment