admin管理员组

文章数量:1391990

Creating the Webapp game as telegram mini app. And stucked with one feature based on the requestWriteAccess.

What i want to achieve is that when i requestWriteAccess from user, it will show pop up as the screen below

I tried this but it shows only the standart telegram bot alert bot as you can see it below

Here is the code we use

const allowsWriteToPm = window.Telegram.WebApp.initDataUnsafe.user.allows_write_to_pm;
    if (!allowsWriteToPm) {
        window.Telegram.WebApp.requestWriteAccess(function(ctx) {
            console.log("[TG] requestWriteAccess: " + ctx);

            if (!ctx || ctx !== "allowed" && String(ctx) !== "true"){
                return;
            }

            TG.trySendGreetMsg();
        });
    } else {
        TG.trySendGreetMsg();
    }

I checked another products and it seems that they have almost the same code.

本文标签: javascriptTelegram requestWriteAccess popup windowStack Overflow