Cordova (phonegap build) white page now?


#1

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?


Intermittent White Screen On Load - NOT Cordova
#2

Try to disable push state


#3

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


#4

because of the push state??


#5

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


#6

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?


#7

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 /


Not showing main page on device
#8

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


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

#10

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?


#11

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)


#12

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


#14

@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!


#15

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


#16

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

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

Framework7 PushState 404 Error on compiled Android app
#17

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();
});

#18

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


#19

Then you have some missconfiguration of routes


#20

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’,
}
]


#21

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