IOS 15 fullscreen problem

Hi Everyone, nice to meet you all.
I am using cocos creator 2.4.6 to create a h5 games, but we encounter a problem on iOS 15 Safari Browser.
I have the following code in the js file:

function initIOS()
{
    window.addEventListener('touchmove', ev =>
    {
        if (!$('#safarihelper').hasClass('active'))
        {
            ev.preventDefault();
        }
    }, { passive: false });
    onWinResize();
    $(window).resize(function () { onWinResize() });
    $(window).on('orientationchange', function () { onWinResize() });
}

function onWinResize()
{
    let w = window.innerWidth;
    let h = window.innerHeight;
    let isFullScreen = false;

    if (window.screen.width === h && window.orientation != 0)
    {
        isFullScreen = true;
    } else
    {
        isFullScreen = false;
    }

    if (!isFullScreen)
    {
        $('body').removeClass('core-scrollcheck-off').addClass('core-scrollcheck-on');
        if (!$('#safarihelper').hasClass('active'))
        {
            $('#safarihelper').addClass('active');
            $('#safarihelper').parents('.safarihelper-bg').addClass('active');
        }
        $('html, body').removeClass('fullscreenSafari').addClass('notFullscreenSafari');
        window.scrollTo(0, 0);
    } else
    {
        $('body').removeClass('core-scrollcheck-on').addClass('core-scrollcheck-off');

        if ($('#safarihelper').hasClass('active'))
        {
            $('#safarihelper').removeClass('active');
            $('#safarihelper').parents('.safarihelper-bg').removeClass('active');
        }
        $('html, body').addClass('fullscreenSafari').removeClass('notFullscreenSafari');
    }
}

initIOS();

I tried using this code on the cocos creator game, but it has the problem, cannot fullscreen. After swipe up, the address bar will popup again.

And after many tries, I discovered if I am not using cocos creator and create an html page, it works perfectly.

Did anyone encounter similar problem and how you guys solve this problem?

Cocos Creator game’s canvas is also listening to the events, so yours probably won’t get invoked, to avoid the issue, you can create an in-game button to invoke your full screen behavior

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.