By clicking on a link inside the webview that will bring up the native iOS screen (with parameters passed from the webview)

Looking at the iOS app for Facebook, you can see that when in a feed (for example), a click on a comment will appear on the native iOS dialog, as well as on a click on a photo, the native iOS screen will also appear, that's the target. Or by clicking "Comments", you will load another iOS screen for that.

I am working on a hybrid iOS app (html5 + obj-c) and will love this functionality. I checked:

http://en.wikipedia.org/wiki/Multiple_phone_web-based_application_framework

But I can't say which one is the best. For example, phonegap is very popular, but I'm not sure if such an implementation with it ("native bridge") is something possible. Even if it does, if it requires me to handle the main learning curve (this is syntax and writing a custom plugin). What would you do? Which FW is most suitable. I am not using ANY system features like camera / file system / etc, Phone delay offers except this native bridge, so think about frame size and that is ONLY the part I need. At the same time, the application should not be 100% phone call or 100% native.

I guess sencha touch 2 cannot be for the purposes of this requirement either.

+3


source to share


2 answers


Yes, you can use your own protocol.

In your html, declare your JS call function:

function callIt(paramText) {
    var iframe = document.createElement("IFRAME");
    iframe.setAttribute("src", "my-protocol://" + paramText.replace(/ /gi,'%20'));
    document.documentElement.appendChild(iframe);
    iframe.parentNode.removeChild(iframe);
    iframe = null;
}

      



On iOS, you will intercept the call by using in your webView webView: shouldStartLoadWithRequest: navigationType:

Check if the request has the "my-protocol:" prefix. In this case, extract your parameter from the request using the ": //" section separator (you can also use any separator you want) and return NO.

+1


source


using only sencha framework you can create your own url scheme calls from javascript code

eg:

window.location='test://'+parameters;

      



In your own part, you need to write a protocol handler when this custom url is called, the handler does the appropriate functions in your native part.

now in the opposite direction, let's say now you want to go from native ios to sencha, you can save your data in a javascript file and use it in the sencha part, you can call functions in javascript from your own code.

you don't need to use phoneGap as you have access to all built-in frameworks

0


source







All Articles