Start a new topic

Cordova/Phonegap sample App problems

Cordova/Phonegap sample App problems


Hi all !
We are encountering an issue while trying to get your Phonegap Augmented Reality samples to work on iOS devices.

i've create the project using CreateSampleApp.sh

In particular it looks like callback functions for success and failure are not executed after method "app.wikitudePlugin.loadARchitectWorld" is called.
Please take a look at this code snippet

// --- Wikitude Plugin ---
// Use this method to load a specific ARchitect World from either the local file system or a remote server
loadARchitectWorld: function(example) {
// check if the current device is able to launch ARchitect Worlds
app.wikitudePlugin.isDeviceSupported(function() {
app.wikitudePlugin.setOnUrlInvokeCallback(app.onUrlInvoke);
// inject poi data using phonegap's GeoLocation API and inject data using World.loadPoisFromJsonData
if ( example.requiredExtension === "ObtainPoiDataFromApplicationModel" ) {
navigator.geolocation.getCurrentPosition(onLocationUpdated, onLocationError);
}

app.wikitudePlugin.loadARchitectWorld(function successFn(loadedURL) {
/* Respond to successful world loading if you need to */
console.log("Entered in callback (loadARchitectWorld)");
}, function errorFn(error) {
alert('Loading AR web view failed: ' + error);
},
example.path, example.requiredFeatures, example.startupConfiguration
);
}, function(errorMessage) {
alert(errorMessage);
},
example.requiredFeatures
);
},

On Android devices all works fine but on any iOS device we can't get it to work.

In addition, we found out that on iOS 8.x the "onUrlInvoke" method doesn't get invoked even though commands such as "javascript: document.location = 'architectsdk://action=captureScreen';" are actually performed:

// This function gets called if you call "document.location = architectsdk://" in your ARchitect World
onUrlInvoke: function (url) {
if (url.indexOf('captureScreen') > -1) {
app.wikitudePlugin.captureScreen(
function(absoluteFilePath) {
alert("snapshot stored at:n" + absoluteFilePath);
},
function (errorMessage) {
alert(errorMessage);
},
true, null
);
} else {
alert(url + "not handled");
}
}

, whilst it works fine on iOS 9.x and iOS 7.x

Are they known issues ?
Is there a patch to install or alternatively is it possible to find a workaround to get those problems fixed as soon as possible ?

Thanks a lot in advance and best regards !

 

any update on this ?

we are considering the purchase of a license fo rSDK+ but these sort of platform/version incompatibilities are pretty worrying.

Hi Sistemi,
We released a Cordova iOS Plugin update last friday. Can you please verify that your issues still exist with this version? Our tests cover all your reported issues, so please let me know if you still encounter issues.

Best regards

Andreas

Hi Andreas,

We've updated to the last release of the plugin (cordova plugin remove and cordova plugin add) and now callbacks seems to work fine on iOS.

but the code app.wikitudePlugin.setOnUrlInvokeCallback(app.onUrlInvoke); still seems to do nothing... the "onUrlInvoke" method doesn't get invoked even though commands such as "javascript: document.location = 'architectsdk://action=captureScreen';" are actually performed from the AR context:

 

// This function gets called if you call "document.location = architectsdk://" in your ARchitect World
onUrlInvoke: function (url) {
if (url.indexOf('captureScreen') > -1) {
app.wikitudePlugin.captureScreen(
function(absoluteFilePath) {
alert("snapshot stored at:n" + absoluteFilePath);
},
function (errorMessage) {
alert(errorMessage);
},
true, null
);
} else {
alert(url + "not handled");
}
}

 

This seems to affect only iOS 8.x

 

It's good to here that the finishedLoading callback is working now.

Have you already tried to put an alert(url); as first line of onUrlInvoke? You can also set a breakpoint in WTARViewController.m line 150 and check if the architectsdk call actually arrives in the Wikitude SDK (If you start your project from within Xcode in debug mode).

Just a general note: if you change the document location using architectsdk a lot and with almost no time between two calls, the UIWebView might actually swallow your calls so that they even don't arrive in our SDK. 

Best regards

Andreas

Hi Andreas,

i tried to put console.log("Entered in onUrlInvoke) but nothing seems to happen.

I set a breakpoint at WTARViewController.m line 150 but XCode is does not stop on it.

 

I would like to remind you that i'm testing on your SampleApp so it's easier for you to make further investigation

Hi Sistemi,
I just tried the cordova example application that is currently available on GitHub and put an onEnterFieldOfVision trigger to the first example 'image on target'. Inside this trigger, I changed the location and received this change in the Cordova application. Can you try this in your own example application please? (I tested it on iOS 8.4 (iPad Mini))

 

Here is my Trackable definition:

var pageOne = new AR.Trackable2DObject(this.tracker, "*", {

drawables: {

cam: overlayOne

},

        onEnterFieldOfVision: function() {

        document.location = 'architectsdk://blubb';

        }

});

 

and the index.js onUrlInvoke

 


onUrlInvoke: function (url) {

        alert(url);

        if (url.indexOf('captureScreen') > -1) {

            app.wikitudePlugin.captureScreen(

                function(absoluteFilePath) {

                    alert("snapshot stored at:n" + absoluteFilePath);

                },

                function (errorMessage) {

                    alert(errorMessage);

                },

                true, null

            );

        } else {

            alert(url + "not handled");

        }

    }

 


Best regards

Andreas


removed and re-added platform iOS and magically it start working.

Thanks for the support

You're welcome!

If you have any furhter questions, don't hesitate to ask!

Best regards

Andreas
Login or Signup to post a comment