2

I'm currently making the move from MobileSDK 4.x to 5.2 for a hybrid remote app with Android and iOS builds, and I need some help on using cordova.js on iOS. I'm observing that cordova.js is not loading from localhost, and any Javascript that references the variable cordova fails. What I've figured out so far from the SDK Docs:

  1. in Chap 9, section "Developing Hybrid Remote Apps," is the traditional advice, "For hybrid remote applications, you are no longer required to host cordova.js or any plug-ins on the server. Instead, you can include cordova.js ashttps://localhost/cordova.js in your HTML source." This is what we've always done (and are currently doing).

  2. Also in Chap 9, very next section, "Using localhost in Hybrid Remote Apps for iOS," it states, "Beginning with version 5.0, Mobile SDK follows Apple’s mandate and deprecates the UIWebView class in favor of WKWebView.... WKWebView enforces a stricter content security protocol than its predecessor and does not support localhost." It goes on to show how to switch back to UIWebView. Since the only local file I need is cordova.js, I'd rather not do this.

  3. Also in Chap 9, in the section "Accessing the Salesforce API with Force.js," are instructions for putting cordova.js into a static resource, but no mention is made where to get cordova.js.

To be clear - if all we need "locally" in a remote hybrid app under iOS is cordova.js, is there no other provision than switching back to UIWebView or serving cordova.js from the server (i.e., from a static resource)? I feel like I'm missing something here... the change notes from 5.1 state, "We’ve replaced our custom WKWebViewEngine plug-in with Cordova's WKWebViewEngine plug-in" which implies Cordova should work with WKWebViewEngine?

If we do need to serve cordova.js from a static resource, which version do I use? I searched the generated project code for cordova.js, and found 4 different versions (by checksum); looking at the header of each file, it looks like there's an iOS version, two Android versions, and even a Node version (part of phonegap-plugin-push). Do I need some type of client side logic to dynamically include the correct cordova.js? What happens the next time we update the MobileSDK and there's a new version of cordova.js? Older app versions will get the newer cordova.js.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.