States doesn't launch with document.addEventListener('deviceready'...)

Hi,

It’s very strange but my app with cordova works very well on android and desktop with this example and without states :

index.js

 var is_mobile;
"use strict";
// retourne si l'appareil est un mobile ou un ordinateur
var detect_mobile = function () {
    if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent
        .match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) ||
        navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)
    ) {
        is_mobile = true;
        console.log("mobile", is_mobile);
    } else {
        console.log("not mobile", is_mobile);
        is_mobile = false;
    }
};

detect_mobile();

if (is_mobile) {
    document.addEventListener('deviceready', function () {
        console.log("Start App");
        //pub.init()
        my_game.initialize() // call your app init function
    })
} else {
    my_game.initialize() // call your app init function
}

main.js

const my_game = {
    initialize: () => {
        // PUT HERE YOUR GAME//////////////////////////////////////////////
        console.log('my game initialize')
        var config = {
            width: 800,
            height: 600,
            type: Phaser.WEBGL,
            parent: 'phaser-example',
            scene: {
                preload: preload,
                create: create,
            },
            callbacks: {
                postBoot: function (game) {
                    game.canvas.style.width = '100%';
                    game.canvas.style.height = '100%';
                }
            },
        };
        var game = new Phaser.Game(config);

        function preload() {
            this.load.image("enemy", "https://i.postimg.cc/qRk6Mhg4/enemy.png");
        }

        function create() {
            var graphics = this.add.image(100, 100, "enemy").setInteractive().setScale(4)
            graphics.on('pointerdown', function (pointer) {
                console.log("touch")
            })
        }
        //////////////////////////////////////////////////////////////GAME
    },
}

But when i change a little bit my main.js with some states, the device is not ready on mobile and phaser is not launching (it works perfectly on desktop). Could you help me because honestly i don’t see what’s wrong. Thanks in advance.

main.js with states

const my_game = {
    initialize: () => {
        // PUT HERE YOUR GAME//////////////////////////////////////////////
        console.log('my game initialize')
        var boot = new Phaser.Class({
            Extends: Phaser.Scene,
            initialize: function boot() {
                Phaser.Scene.call(this, {
                    key: 'boot'
                });
            },
            preload: function () {
                this.load.image("enemy", "https://i.postimg.cc/qRk6Mhg4/enemy.png");
            },

            create: function () {
                this.add.image(200, 200, "enemy")
            },
        });
        var splash_screen = new Phaser.Class({
            Extends: Phaser.Scene,
            initialize: function splash_screen() {
                Phaser.Scene.call(this, {
                    key: 'splash_screen'
                });
            },
            create: function () {
                this.add.image(500, 400, "enemy")
            },
        });
        var config = {
            type: Phaser.WEBGL,
            width: 640,
            height: 1280,
            backgroundColor: '#ff0',
            parent: 'phaser-game',
            physics: {
                default: 'matter',
                matter: {
                    debug: false,
                    gravity: {
                        y: 0,
                        x: 0,
                    }
                },
            },
            callbacks: {
                postBoot: function (game) {
                    game.canvas.style.width = '100%';
                    game.canvas.style.height = '100%';
                }
            },
            scene: [boot, splash_screen]
        }
        var game = new Phaser.Game(config);
    },
}