Cordova (phonegap build) white page now?

hello i m confused, in the past i had a running v2 version.

now i tried out the stable and after my splash i get a white screen.
does anyone have an idea what the problem could be?

1 Like

Try to disable push state

You get a white screen because it doesn’t load your default route.

because of the push state??

Because it is wrong configured. In phonegap/cordova app the default URL is not just “/”

okay so the pushState can be on true but i have to change the “/” routes on my routes.js and on my index.html?
do you know the default path?

do the console.log(document.location.href) when it run in cordova app. If it is something like file:///Users/something/someapp/www/index.html then you need to specify

pushStateRoot: '/Users/something/someapp/www/'

And the init URL set on view and in routes must be index.html then instead of just /

the adress is “file:///android_asset/www/index.html” but i thing on ios it will be different.
some dynamic option would be good hm

pushStateRoot: Framework7.device.ios ? 'ios-url-here' : 'android-url-here'

okay now it work i added /index.html and /index.html to index.html and routes.js

maybe we can remove file:/// and index.html from document.location.href for dynamic out of box work?

why it is needed now and on the f7 v1.* not.

it is not really easy anymore, because now i have to add all the possible devices

/data/com.adobe.phonegap.app/files/phonegapdevapp/www/ is not working for the phongap dev app :frowning:
/data/com.adobe.phonegap.app/files/phonegapdevapp/www (without slash is broken …)

ps must it /index.html or without slash (only working with leading slash on android)

You can just try set it to document.location.pathname.split(‘index.html’)[0]

2 Likes

@nolimits4web

document.location.pathname.split(‘index.html’)[0]

works also great for ios phone / tablet. maybe we can make a cordova property which make this automaticlly. i think everyone need this with pushState + cordova!

2 Likes

Hello, thank God I have found this post coz I have been scratching my head all week on this.

Unfortunately, I can’t seem to get this to work. I do not think I quite follow you guys on where to add this line of code.

document.location.pathname.split(‘index.html’)[0]

Where does it go? :confused:

Thanks

It goes to pushStateRoot parameter under the view for which you have enabled pushState:

...
pushState: true,
pushStateRoot: document.location.pathname.split(‘index.html’)[0]
...
1 Like

Guys i will advise you to DISABLE push state in cordova apps! Why do you need it there? Only to be able to go back with hardware back button on Android devices only? There is more flexible solutions for this using backbutton event:

$(document).on('backbutton', function (e) {
  e.preventDefault();
  // for example, based on what and where view you have
  mainView.router.back();
});
5 Likes

I do not enable pushstate. Is it enabled by default?

Then you have some missconfiguration of routes

This is my route configuration:

var routes = [
{
path: ‘/’,
url: ‘./index.html’,
name: ‘home’,
},
{
path: ‘/question/:id/’,
componentUrl: ‘./pages/question.html’,
},
{
path: ‘/answer/:id/’,
componentUrl: ‘./pages/answer.html’,
}
]

More details, Cordova or web app? Platform iOS or Android? Any webview plugins like WKWebView? Any errors in developer console?