Unity Ads / Snapchat Playable Ad and MRAID usage

Looking at the sample project called Cube Jump (PlayCanvas | HTML5 Game Engine) while developing the Playable Ads for various platforms I came to the point where I need help / suggestions.

In the beginning I was making a playable for UnityAds which utilizes mraid.js various functions and made a script which loads before the engine:

if (mraid && mraid.getState() === 'loading') {
    mraid.addEventListener('ready', onSdkReady);
} else {
    onSdkReady();
}

function onSdkReady() {
    mraid.addEventListener('viewableChange', viewableChangeHandler);
    // Wait for the ad to become viewable for the first time
    if (mraid.isViewable()) {
        if (pc.Application.getApplication()) {
            pc.app.fire('playable:viewable');
        } 
    }
}

function pcGameReady() {
    if (pc && pc.Application.getApplication() && mraid && mraid.isViewable()) {
        pc.app.fire('playable:viewable');
        pc.app.fire('music:play');
    }
}

In the start.js script we use:

Start.prototype.postInitialize = function() {
    pcGameReady();
};

The challenge for the Snapchat Playable Ads is to utilize these mraid.getState() and mraid.isViewable().

BTW the Rest-Api-Tool fails on having before-engine scripts and “extern_files.enabled”: true.

:computer: The question is should we try to make playable utilize the features of the mraid or we should keep it simple without too much over-engineering ?

Thanks in advance :rocket:

Is this the same issue? https://github.com/playcanvas/playcanvas-rest-api-tools/issues/41

Is this the same issue? https://github.com/playcanvas/playcanvas-rest-api-tools/issues/41

yaustar Yes, this is related.

Do you know about the support of mraid.getState() and mraid.isViewable() in Snap Playable Ads?

Since Snap do not have a Playable test tool it will be a challenge to live test it.

Thanks in advance!

Unfortunately, I don’t :frowning: You will have to ask through your Snap contact. AFAIK, if it’s part of MRAID, it should be support but don’t quote me on that

I also have a branch/PR waiting with the fix for the issue with the script being added before the engine: https://github.com/playcanvas/playcanvas-rest-api-tools/pull/43

Thank you for your help, I’ll will post here an update regarding the MRAID thenever I will have some details on that. Thanks one’s again !