How to start using Phonegap Build with the Durandal SPA App?

I built a SPA using Durandal and it all works fine in the browser. What I'm trying to do now is wrap it with Phonegap (ideally using Phonegap Build) and deploy it as an Android app.

Durandal's documentation on this subject ( http://durandaljs.com/documentation/Native-Apps-With-PhoneGap-Cordova/ ) is pretty rare. The main points of optimizing the application for creating the main-built.js file were the same as collecting js / css assets in one place.

However, he does not mention anything about Phonegap / Cordova having an event device ready, not document ready. I packaged the application according to the instructions. It installs on my Android device, but is stuck on the splash screen. Other questions ask that you are stuck on a pop-up screen, but the solutions posted there do not help. I cannot help but think that something fundamentally absent here?!?

Do I need to have a special Phonegap code in index.html? In any javascript?

Note. I am using Durandal 1.2, but the same questions apply to version 2.0.

+4
source share
3 answers

Phonegap main.js, , , - , . , . Durandal 2/Phonegap Build.

https://github.com/BenSinnott/LandmarkTracker


define(['durandal/app', 'durandal/viewLocator', 'durandal/system'], boot);

function boot(app, viewLocator, system) {
    var useragent = navigator.userAgent.toLowerCase();
    if (useragent.match(/android/) || useragent.match(/iphone/) || useragent.match(/ipad/) || useragent.match('ios') || useragent.match('Windows Phone') || useragent.match('iemobile')) {
        document.addEventListener('deviceready', onDeviceReady, false);
    }
    else {
        onDeviceReady();
    }

    function onDeviceReady() {
        app.title = 'Landmark Tracker';

        app.configurePlugins({
            router: true
        });

        app.start().then(function () {
            viewLocator.useConvention();
            app.setRoot('viewmodels/shell', 'entrance');
        });
    }
}

+7

, Phonegap/Cordova , , .

jQuery $(document).ready, HTML/javascript , . javascript DOMContentLoaded. Phonegap/Cordova , . <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <head></head>.

Android-, .

config.xml. <preference name="splash-screen-duration" value="xxxx"/>, xxxx - ?

navigator.splashscreen.hide() , , deviceready. , . , , , .

+2

, . . logcat. , js. , - , logcat

: sry , , android, -. IOS, , , .

+1

All Articles