Xcode6 UIWebView and JavaScript interaction (issue fix), xcode6uiwebview
This article describes the interaction between UIWebView and JavaScript. In UIWebView, JavaScript request processing is intercepted. From the app perspective, this is a JavaScript Hook request.
In App versions earlier than Xcode6, JavaScript can send Hook requests as follows:
HTML:
<li><a href="testapp://function=test&callbackJS=testCallback">test link</a></li>
JavaScript:
<script language="JavaScript" type="text/javascript"> function xcode6(){var url = apptest://function=test&callbackJS=testCallback;location.href = url; }</script><li><a href="Javascript:xcode6();">Xcode6 Javascript</a></li>
In the Xcode6 App, it is found that the href method changed through JavaScript is unavailable. From the app perspective, (BOOL) webView :( UIWebView *) webView shouldStartLoadWithRequest :( NSURLRequest *) request navigationType :( UIWebViewNavigationType) navigationType is not called.
Solve this problem through escape URL:
<script language="JavaScript" type="text/javascript"> function xcode6(){var url = 'apptest://'+escape('function=test&callbackJS=testCallback');location.href = url; }</script><li><a href="Javascript:xcode6();">Xcode6 Javascript</a></li>
For ios UIWebView, how does javascript call system services?
The most common interaction method in ios is to implement webview through URL Scheme. shouldStartLoadWithRequest :( NSURLRequest *) request navigationType :( UIWebViewNavigationType) navigationType can be used to process various URL Scheme. For example:-(BOOL) webView :( UIWebView *) webView shouldStartLoadWithRequest :( NSURLRequest *) request navigationType :( UIWebViewNavigationType) navigationType {
NSLog (@ "shouldStartLoadWithRequest called ");
NSURL * url = [request URL];
If (! [[Url scheme] isw.tostring: CUSTOM_PROTOCOL_SCHEME]) {
Return YES;} NSString * actionType = [url host];
If ([actionType ispolictostring: @ "alert"]) {
NSLog (@ "alert called ");
NSString * JSONString = [
[[Url fragment] stringByReplacingOccurrencesOfString: @ "+" withString: @ ""] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[[IToast makeText: NSLocalizedString (JSONString, @ "")] show];} return NO;} in this way, you can: var url = schema + ": // alert "+" # "+ encodeURIComponent (msg );
Document. location = url; call object c to update in the opposite direction:
UIWebView has one problem.
It is difficult to make it clear. Because most 3000 boards can be saved before they have to be charged, once the power is off, the motherboard will automatically restore a real country that won't recognize your pirated game. This is normal. Generally, the sales host owner can crack the software (Real System Identification and operation of the signature) during the running time and identify the game. However, you also said, it is unclear how you and your brothers click it. Said, when you buy a machine, the boss God, instead of disturbing your account on your machine, such training and preparation, then you throw the money to the boss to stay? Did not communicate with each other?