Start a new topic

loadARchitectWorld not calling callback - Cordova on iOs

loadARchitectWorld not calling callback - Cordova on iOs


Hello, I have a problem: I'm implementing image recognition with plugin cordova wikitude so, it works very well on Android but doesn't on iOs. This is the snippet on side cordova:

var app = {

 

     isDeviceSupported: false,

 

     initialize: function() {

          app.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");

          app.loadARchitectWorld();

     },

 

     loadARchitectWorld: function() {

 

          var example = {

               "path": "www/world/1_ClientRecognition_4_Interactivity/index.html",

               "requiredFeatures": ,

               "startupConfiguration": {

                    "camera_position": "back"

               }

          };

 

          app.wikitudePlugin.isDeviceSupported(function() {

 

               app.wikitudePlugin.loadARchitectWorld(function successFn(loadedURL) {

                    console.log("loadARchitectWorld: "+loadedURL);

                    app.wikitudePlugin.callJavaScript("welcomeAlert()");

 

               }, function errorFn(error) {

                    alert('Loading AR web view failed: ' + error);

               },

               example.path, example.requiredFeatures, example.startupConfiguration

          );

          }, function(errorMessage) {

               alert(errorMessage);

          },

          example.requiredFeatures

          );

     }

};

 

app.initialize();

 

The problem is that in iOs it doesn't enter in callback success (or callback error) of loadARchitectWorld. In this way I can't run the callJavascript. Why??? After the code of my World:

 

var World = {

     loaded: false,

 

     init: function initFn() {

          this.createOverlays();

     },

 

     createOverlays: function createOverlaysFn() {

          this.tracker = new AR.ClientTracker("assets/magazine.wtc");

 

          var imgOne = new AR.ImageResource("assets/imageOne.png");

          var overlayOne = new AR.ImageDrawable(imgOne, 1, {

               offsetX: -0.15,

               offsetY: 0

          });

 

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

               drawables: {

                    cam: overlayOne

               }

          });

     },

};

 


function welcomeAlert() {

     alert("Welcome to World");

     World.init();

}


 

Same here. I'm using v5.0.1-3.2.0-beta.1. Neither successCallback nor errorCallback are called. Android works as expected.

Hi,
Can you please try out our latest Cordova update which was release just a couple of days ago? We fixed the mentioned callbacks on iOS.

Best regards

Andreas

Was this ever confirmed to work? I'm trying to use the sample application code with the success callback in loadARchitectWorld, but it does not seem to ever get called. I can introduce an erroneous load condition and cause the failure callback to fire, but the success one does not even when a world loads. I'm using version 5.1.4-3.2.1.

Yes, it works now. Somehow our old API was still used for the WTArchitectViewDelegate implementation in our Wikitude Cordova Plugin.

The update is already in our master branch on GitHub.

Best regards

Andreas

I've same problem in version Cordova Plugin 5.2.0-3.3.1. 

 

In IOS the callback success is receipt only on return to main app.

In Android it work.

Hi Julien,
I just tried it again with a example application that I freshly created and the callback was called correctly for me.

Are you sure that you use our latest module? Have you tried to add an alert to the onLoaded callback?

Here is a snippet how I tested the functionality:

app.wikitudePlugin.loadARchitectWorld(function successFn(loadedURL) {

                    alert('world ' + loadedURL + 'loaded');

                    /* Respond to successful world loading if you need to */

                    app.isArchitectWorldLoaded = true;

 

                    /* in case the loaded Architect World belongs to the 'obtain poi data from application model' example, we can now safely inject poi data. */

                    if ( architectWorld.requiredExtension === "ObtainPoiDataFromApplicationModel" ) {

                        injectGeneratedPoiJsonData();

                    }

                }, function errorFn(error) {

                    app.isArchitectWorldLoaded = false;

                    alert('Loading AR web view failed: ' + error);

                },

                architectWorld.path, architectWorld.requiredFeatures, architectWorld.startupConfiguration

            );

Best regards,

Andreas

Hi Andreas,

After code refactoring it works with  5.2.0-3.3.1.
But I have the feeling that for each new app launch, when i first scan the target the  onEnterFieldOfVision event is not detect. If I go out of my target, then returns the event is detected.( Only IOS )
This remains to be verified.

Best regards

Hi Julien,
This sounds very strange as this is one of the things we constantly test. Are you using our example application or your own application?

Can you send us a video showing the effect?

Best regards,

Andreas

Hi,

 

We have done more tests and we have isolate an problem.

 

we use : 

 

onUrlInvoke(url) {
app.wikitudePlugin.close();
}

 

 

Upon detection of a target we send :

document.location = "architectsdk://.....";

 

However Wikitude not close all the time. In the majority of cases it closes, but occasionally it does not close. (IOS only)

Same for " hide() ";

 

I haven't succeeded in reproducing with your sample.

For information, we use wikitude with Meteor.

 

Thanks for your help

Hi Julien,
What is Meteor?

We noticed that in case a dom manipulation is triggered, document.location changes might be ignored by the web view as it already prepares for a page reload. Do you trigger any dom changes in case a target is recognized? If that's the case, a setTimeout(300ms) around the document.location = "architectsdk://" helped for us.

Best regards,

Andreas

Hi Andreas,

 

Yes document.location changing when an target is recognized. I have tested  : 

 

setTimeout(function(){
var architectSdkUrl = "architectsdk://" + encodeURIComponent(World.targetNameCurrent);
document.location = architectSdkUrl;
}, 300);

 

But the solution not Working :/

 

You can see Meteor here : https://www.meteor.com/

 


Best regards,

Andreas

Hi Julien,
Can you confirm that in case the Wikitude Cordova plugin is not closed, the `onUrlInvokd` callback is not called as well?

Best regards,

Andreas

Hi Andreas,

Yes I confirm.

Best regards
Login or Signup to post a comment