Start a new topic

Close PhoneGap Plugin doesn't work for iOS

Close PhoneGap Plugin doesn't work for iOS
1 Comment


Hello,

I implement an application for iOS and Android with Cordova and the Wikitude plugin. I want to realize a back button in an actionbar with HTML which closes the architect world. For Android it works fine, but not for iOS. Here is my code:

index.html:

<script>

var book = {
                "path": "www/book/book.html",
                "requiredFeatures": ,
                "startupConfiguration": {
                    "camera_position": "back"
                }
            };

</script>

There a path is set to navigate to another html page (book.html). In this html page I want to load the ar stuff.

When I click on the button which is below, the architect world loads:

<button id="button" onclick="javascript:app.loadARchitectWorld(book);" >Start</button>

The called method app.loadARchitectWorld(book) is part of the index.js.

index.js


var app = {

    // represents the device capability of launching ARchitect Worlds with specific features
    isDeviceSupported: false,

    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    onDeviceReady: function() {
        app.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
    },
    // --- Wikitude Plugin ---
    // Use this method to load a specific ARchitect World from either the local file system or a remote server
    loadARchitectWorld: function(book) {
        // check if the current device is able to launch ARchitect Worlds
        app.wikitudePlugin.isDeviceSupported(function() {

            // setting up a callback to communicate from ARchitect into PhoneGap
            app.wikitudePlugin.setOnUrlInvokeCallback(app.onURLInvoked);

            app.wikitudePlugin.loadARchitectWorld(function successFn(loadedURL) {
                /* Respond to successful world loading if you need to */
            }, function errorFn(error) {
                alert('Loading AR web view failed: ' + error);
                console.log("AR web view can't load");
            },
            book.path, book.requiredFeatures, book.startupConfiguration
            );
        }, function(errorMessage) {
            alert(errorMessage);
        },
        book.requiredFeatures
        );
    },
    onURLInvoked: function(url) {
        if ( 'closeWikitudePlugin' == url.substring(22) ) {
            app.wikitudePlugin.close();
        } else {
            console.log('ARchitect => PhoneGap ' + url);
        }
    }

};

app.initialize();

This is part of a wikitude sample project. In the book.html which belongs to the architect world exists a back button. With jQuery I execute

document.location = 'architectsdk://action=closeWikitudePlugin';


Then I want to close the wikitude plugin and display the index.html again.

For Android it works fine, but when I launch my app from an iOS device, nothing happens when I click on the back button. I want to use two html pages because the first is a welcome page and the other one is for the architekt world.

Thanks for your help!
Login or Signup to post a comment