high-level methods for webview apps #74

Closed
opened 2024-10-07 17:34:15 +03:00 by Vance-ng-vn · 1 comment
Vance-ng-vn commented 2024-10-07 17:34:15 +03:00 (Migrated from github.com)

Is your feature request related to a problem? Please describe.
Missing Endpoint messages.requestAppWebView

Describe the solution you'd like
Add messages.requestAppWebView

Additional context

There is an alternative method called requestWebView, but it seems this method requires entering a URL for the mini app, whereas the requestAppWebView method does not require a URL

https://core.telegram.org/method/messages.requestAppWebView

await this.client.call({
    _: 'messages.requestAppWebView',
    app: {
        inputBotAppID: id,
        inputBotAppShortName: shortName
    },
    peer: toInputPeer(await this.client.resolvePeer(id)),
    platform: 'web'
});
Error: Unknown object undefined
    at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:251:39)
    at messages.requestAppWebView (/home/mx-vankaiser/Projects/Telegram Bot/not-pixel/node_modules/@mtcute/tl/binary/writer.js:1735:311)
    at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:252:26)
    at Object.initConnection (/home/mx-vankaiser/Projects/Telegram Bot/not-pixel/node_modules/@mtcute/tl/binary/writer.js:1377:432)
    at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:252:26)
    at Object.invokeWithLayer (/home/mx-vankaiser/Projects/Telegram Bot/not-pixel/node_modules/@mtcute/tl/binary/writer.js:1378:74)
    at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:252:26)
    at TlSerializationCounter.countNeededBytes (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:188:9)
    at TlBinaryWriter.serializeObject (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:312:74)
    at SessionConnection.sendRpc (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/core/chunks/es/BJRm2PAH.js:5272:34)
**Is your feature request related to a problem? Please describe.** Missing Endpoint messages.requestAppWebView **Describe the solution you'd like** Add messages.requestAppWebView **Additional context** There is an alternative method called requestWebView, but it seems this method requires entering a URL for the mini app, whereas the requestAppWebView method does not require a URL https://core.telegram.org/method/messages.requestAppWebView ```javascript await this.client.call({ _: 'messages.requestAppWebView', app: { inputBotAppID: id, inputBotAppShortName: shortName }, peer: toInputPeer(await this.client.resolvePeer(id)), platform: 'web' }); ``` ``` Error: Unknown object undefined at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:251:39) at messages.requestAppWebView (/home/mx-vankaiser/Projects/Telegram Bot/not-pixel/node_modules/@mtcute/tl/binary/writer.js:1735:311) at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:252:26) at Object.initConnection (/home/mx-vankaiser/Projects/Telegram Bot/not-pixel/node_modules/@mtcute/tl/binary/writer.js:1377:432) at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:252:26) at Object.invokeWithLayer (/home/mx-vankaiser/Projects/Telegram Bot/not-pixel/node_modules/@mtcute/tl/binary/writer.js:1378:74) at TlSerializationCounter.object (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:252:26) at TlSerializationCounter.countNeededBytes (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:188:9) at TlBinaryWriter.serializeObject (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/tl-runtime/index.js:312:74) at SessionConnection.sendRpc (file:///home/mx-vankaiser/Projects/Telegram%20Bot/not-pixel/node_modules/@mtcute/core/chunks/es/BJRm2PAH.js:5272:34) ```
teidesu commented 2024-10-07 17:54:31 +03:00 (Migrated from github.com)

you are calling it wrong, please don't ignore typescript errors

it should be either:

const bot = await tg.resolvePeer('wallet')
await tg.call({
    _: 'messages.requestAppWebView',
    app: {
        _: 'inputBotAppShortName',
        botId: toInputUser(bot),
        shortName: 'whatever'
    },
    peer: bot,
    platform: 'web'
});

or

const bot = await tg.resolvePeer('wallet')
await tg.call({
    _: 'messages.requestAppWebView',
    app: {
        _: 'inputBotAppID',
        id: Long.fromString('...'),
        accessHash: Long.fromString('...')
    },
    peer: bot,
    platform: 'web'
});

(and you most likely want the former)

though keeping the issue open for high-level methods for webviews, they are long overdue tbh

you are calling it wrong, please don't ignore typescript errors it should be either: ```ts const bot = await tg.resolvePeer('wallet') await tg.call({ _: 'messages.requestAppWebView', app: { _: 'inputBotAppShortName', botId: toInputUser(bot), shortName: 'whatever' }, peer: bot, platform: 'web' }); ``` or ```ts const bot = await tg.resolvePeer('wallet') await tg.call({ _: 'messages.requestAppWebView', app: { _: 'inputBotAppID', id: Long.fromString('...'), accessHash: Long.fromString('...') }, peer: bot, platform: 'web' }); ``` (and you most likely want the former) though keeping the issue open for high-level methods for webviews, they are long overdue tbh
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: teidesu/mtcute#74
No description provided.