John D
John D

Reputation: 76

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 'deviceready', and as a result i cannot get the new parameters.

Any ideas? Thanks!

Upvotes: 3

Views: 1951

Answers (3)

keune
keune

Reputation: 5795

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
}

Upvotes: 0

rwbutler
rwbutler

Reputation: 387

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!

Upvotes: 4

Shazron
Shazron

Reputation: 2488

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

Upvotes: 0

Related Questions