Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have my website setting up the unity webapp integration on load. In contrast to Firefox, Chromium hasn't the API available immediately after loading the page.
Is there any best practice how to wait for the API to become available or should I just recheck after a couple of seconds?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The example below (from here) shows the event unity-webapps-api-ready will fire when the API is available. I'm not sure where this is officially documented, but it seems to work for me.

function onApiReady() {
    Unity = external.getUnityObject(1.0); 
    Unity.init({name: "Unity Web Tutorial",
        iconUrl: "http://www.ubuntu.com/tutorialIcon.png",
        onInit: unityReady});
}

if (navigator.userAgent.search('Chromium') >= 0) {
    // Wait until WebApps API is available
    document.addEventListener('unity-webapps-api-ready', onApiReady);
} else {
    onApiReady();
}
share|improve this answer
    
Thank you! That was what I've been searching for. I haven't found any documentation on that. –  MeinAccount Oct 28 '13 at 7:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.