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

Call the close function #10

Closed FredrikHa closed 7 years ago

FredrikHa commented 8 years ago

Need some help to call Ionicitude.close();

I have created a button width a onclick="close()"

Where should i put the close() call.

Can i create a <script></script> before the body end tag?

Tazaf commented 7 years ago

Hi, Sorry for not responding earlier to your issue. Based on the code you send me on your email...

<div class="float-button top-right">
    <span class="height-fix">
        <a class="content" onclick="closeWikitudePlugin()">
            <i class="ion-ios-close-empty"></i>
        </a>
    </span>
</div>     
<!-- loads Studio project -->
<script src="js/content_mini.js"></script>
<script>
    function closeWikitudePlugin(){
        Ionicitude.close();
    }
</script>

...you can't use Ionicitude directly from within the AR World JS code: it's only available in the Ionic side of your app. So, to close the AR View with a button that's placed inside it, you need to replace your closeWikitudePlugin() body with something like that:

function closeWikitudePlugin() {
    document.location='architectsdk://close';
}

With close being the name of an action that you'd have registered with Ionicitude.addAction() at the app startup.

I recommand that you read this section of the documentation : https://github.com/Tazaf/ionicitude#interaction-between-the-ionic-app-and-the-ar-view

You could also check the demo app to see this communication mechanism in "action".

FredrikHa commented 7 years ago

Thanks. It's makes sense!

I'm really impressed about your work @Tazaf. Keep up the good work!