开发者

PhoneGap iOS application 'deviceready' event - initial entry vs resume

I am using PhoneGap to create a native iOS app. The app implements an iOS scheme so that it can be invoked from mobile Safari like myapp://?parameters. The app activities depend on the input parameters, i read those by handling the 'deviceready' event.

The problem is that after initial execution the app remains in the background, and any subsequent calls (from the browser) do not fire another 'de开发者_运维知识库viceready', and as a result i cannot get the new parameters.

Any ideas? Thanks!


Did you manage to get the resume event to fire in the end?

I'm having trouble with this as well - I have the following code:

window.addEventListener('load', function () {
    document.addEventListener('deviceready', onDeviceReady, false);
}, false);

function onDeviceReady() {
    document.addEventListener('resume', onResume, false);
    document.addEventListener('pause', onPause, false);
    document.addEventListener('online', onOnline, false);
    document.addEventListener('offline', onOffline, false);
}

function onResume() {
    alert('resume');
}

function onPause() {
    alert('pause');
}

function onOnline() {
    alert('online');
}

function onOffline() {
    alert('offline');
}

And although the deviceready and online events appear to be firing, I can't seem to get the resume event to fire. Any light anyone could shed on this would be much appreciated!


There is a 'resume' event. http://docs.phonegap.com/phonegap_events_events.md.html


It has been more than a year since the question was asked, but I want to reply for future readers anyway.

If you want your app to respond to url schemes after the initial load( on resume ), you need to define a function called handleOpenURL() in global context. Then this function will automatically be fired when your app resumes.

function handleOpenURL(invokeString) {
  // do something with the invoke string
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜