Tazaf / ionicitude

AngularJS module for using the Wikitude cordova plugin in an Ionic project.
http://tazaf.github.io/ionicitude/
MIT License
24 stars 10 forks source link

AR world launches before device support check. #3

Closed GeoffSeloana closed 8 years ago

GeoffSeloana commented 8 years ago

Ionicitude is a great solution which will make all the ionic dev's lives simpler.

I have noticed a slight problem which causes the app to crash due to unsupported feature error. The AR world launches before the device check is confirmed to be supported.

Please address this issue.

Thank you.

Tazaf commented 8 years ago

As a complement, it should be noted that this problem occurs only when trying to launch an AR World right when the app starts.

In any case, the commit 49a6862b82a6e1a336cc3cb8710dfad492bfc903 should solve the problem.

It adds a new method to Ionicitude, the ready() method, which works very much like the $ionicPlatform.ready() method. You just need to encapsulate the code that you want to execute in an anonymous function, passed as the method parameter. This ensures that the code is executed only when Ionicitude has finished initializing itself.

Ionicitude.ready(function() {
    Ionicitude
        .launchAR('myAR')
        .then(function(success) {
            // React to successful launching
        }
        .catch(function(error) {
            // React to unsuccessful launching
        }
});

It also changes a little bit the init() function in that this method doesn't return the service, but act as a promise to which you can react (this was needed for implementing the ready() function). This shouldn't impact your code, though.

To test that this solution is convenient, please download the latest version on the dev branch. If this solves the problem, please report it here so that I can close the issue, update the doc and push these modifications to the master.

Thanks for your support :wink:

GeoffSeloana commented 8 years ago

Fantastic, it’s working great. Thank you so much.