Start a new topic

loadARchitectWorld not calling callback - Cordova on iOs

loadARchitectWorld not calling callback - Cordova on iOs

1 person has this problem


Hi Julien,
We already decided to deprecate the document.location = architectsdk:// approach with something new. This will ship later this year. Until then I'm not sure how we proceed with this. You could try to increase the timeout. Otherwise it's a web view internal issue that these location changes are not reported correctly.

Best regards,

Andreas

Hi wiki supporter,

I am facing this issues. on iOS, sometimes it is not calling callback on the first launch.

Here is my code:

  

wikitudePlugin.loadARchitectWorld(function successFn(loadedURL) {
        console.log('LoadedUrl: ', loadedURL);
        /* Respond to successful world loading if you need to */
        app.isArchitectWorldLoaded = true;
  
        app.wikitudePlugin.callJavaScript(stringSent);

        /* 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;
        app.wikitudePlugin.callJavaScript('alert(\'Launch AR Error!\')');
      },
      architectWorld.path, architectWorld.requiredFeatures, architectWorld.startupConfiguration
    )

 Sometimes, success callback is not called, any advices? 

Hi Huy,


Could you please provide further details on the issue:

  • Which version of the SDK are you using?
  • Are you using the JS API?
  • Are you using any of our Extensions (Titanium, Cordova, Xamarin, Unity)? If yes, which version are you using?
  • please send the crash log
  • What device does this happen with (os Version and model)?
  • Is this happening with the sample app or in your own app? If it happens with your own app, does the sample app work on your device?
  • Send exact steps to reproduce this issue and a video so we can check how we can reproduce this issue

Thanks

Eva

Hi,

Thanks for your response.

It is a Cordova Project.

I used cordova plugin latest code, 7.1.2 

Test on iPad and iPhone iOS 11.

Please check my log code above:

this code is not alway called when we launch 

console.log('LoadedUrl: ', loadedURL);


Thanks,

Huy



1 person likes this

Hi everyone ,

I have the same problem as you Huy le on ios   .
but when i rotate the phone i got alert message saying ( setBackButton callback is only availble on android and not on ios ) and then the code inside the callback function is called .

and xcode log give that error :


<MainViewController: 0x10290e3a0> whose view is not in the window hierarchy!


I use cordova sdk v  7.1.2  and IOS11



Thanks 



Hi wikitude team,

Any advice on this issue?


Thanks,

Huy

Hi,



I just tested this with our Cordova sample app on an iPhone 8 running iOS 11 and found it to be working. I used version 7.2.1 of the SDK. Have you tried this version yet?


Otherwise I'd be interested to know whether you are having this issue in your own application or our sample app. If it is the former, I'd like you to try using our sample app and checking whether the same thing happens.


We offer a script to conveniently set the sample app up. Here's the documentation page that shows how.



- Daniel


I'm experiencing a similar issue on iOS.

Sometimes the success callback is called - sometimes not. In the latter case the error callback is also not called.


It seems pretty random when and when not the success callback is being executed...


My code:

import React, {Component, PropTypes} from 'react';

export default class ARDemoView extends Component {
    constructor(props) {
        super(props);

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

        // this.sample = {
        //     path: "http://192.168.43.4:3000/ar/samples/01_ImageTracking_1_ImageOnTarget/index.html",
        //     requiredFeatures: [
        //         "image_tracking"
        //     ],
        //     startupConfiguration: {
        //         "camera_resolution": "auto",
        //         "camera_position": "back"
        //     }
        // };

        this.sample = {
            "path": "http://192.168.0.102:3000/ar/samples/01_ImageTracking_1_ImageOnTarget/index.html",
            "requiredFeatures": [
                "image_tracking"
            ],
            "startupConfiguration": {
                "camera_resolution": "auto",
                "camera_position": "back"
            },
            "extraData": {
                "key1": "test",
                "key2": "test2"
            }
        }

        this.wikitudePlugin.isDeviceSupported(this.onDeviceSupported.bind(this), this.onDeviceNotSupported, this.sample.requiredFeatures);
    }

    onDeviceSupported() {
        console.log("DEVICE SUPPORTED!");

        this.wikitudePlugin.requestAccess(
            this.onRequestPermissionSuccessful.bind(this),
            this.onRequestPermissionError.bind(this),
            this.sample.requiredFeatures);

    }

    onDeviceNotSupported(error) {
        console.log("DEVICE NOT SUPPORTED", error);
    }

    onRequestPermissionSuccessful() {
        console.log('loadArchitectWorld', this.wikitudePlugin);
        console.log('loadArchitectWorld', this.sample.path);
        this.wikitudePlugin.loadARchitectWorld(
            this.onARExperienceLoadedSuccessful.bind(this),
            this.onARExperienceLoadError.bind(this),
            this.sample.path, this.sample.requiredFeatures, this.sample.startupConfiguration
        );
    }

    onRequestPermissionError(error) {
        /* The error object contains two error messages.
            * userDescription is a end user formatted message that can be displayed with e.g. a JS alert
            * developerDescription is a developer formatted message with more detailed information about the error
         */
        /* Here, the userDescription is used to show a confirmation box which, in case of a positive result, shows the applications settings so that user can grant access. */
        var openAppSettings = confirm(error.userDescription + '\nOpen App Settings?');
        if (openAppSettings == true) {
            this.wikitudePlugin.openAppSettings();
        }
    }

    onARExperienceLoadedSuccessful() {
        console.log("LOADED");
        const array = ["a","b", "c", 6];
        this.wikitudePlugin.callJavaScript(
            `
            AR.logger.setHTMLLoggingEnabled(true);
            World.params = {
                trackerFile: "assets/magazine.wtc",
                overlayImage: "assets/imageOne.png",
                thumb: "assets/surfer.png"
        
            }
            World.createOverlays('puta');
            AR.logger.info("overlaysCreated");
            
            `
        )
    }

    onARExperienceLoadError(error) {
        console.log("LOAD ERROR", error);
    }

    render() {
        return (
            <div>
                <p>AR View</p>
            </div>
        )
    }
};

ARDemoView
    .propTypes = {};

 

I found out an interesting fact - somehow it seems as if the AR view is being paused or something.


 If the success callback of loadARchitectWorld is not called and it switch the app to the background and return or do any other "native" UI interaction such as swiping open the settings from top or a double home button press - the view is "re-iniated" and the callback is called. I think this is somekind of bug in the plugin.

Hi Mark,


So the issue is solved for you now?


Greetings

Nicola

Hi Nicola,


No unfortunately it is not - above mentioned behaviour is still happening.

I opened a new topic for it here with example code + behaviour video's.


https://support.wikitude.com/support/discussions/topics/5000088559


Best,


Mark

Login or Signup to post a comment