Skip to content

requestContact method does not invoke callback function #52

@WhatNot911

Description

@WhatNot911

Code sample:

WebApp.requestContact((access: boolean, response?: RequestContactResponse) => {
    console.log('request contact callback call')
    try {
        if (!response) throw new Error("Horrible error")        
        if (!access || response.status === "cancelled") throw new Error("Plz give access")
        localStorage.setItem("telegram-contact", JSON.stringify(response.responseUnsafe.contact)) // Fix safety issue l8r
    } catch (e) {
        ErrorHandler.Error("Error", e instanceof Error ? e.message : this.InternalError)
    }
});

Expected behaviour:

console produces logs like "request contact callback call", localStorage receiving an object, UI error display on cancelation/error

What really happens:

regardless of which button has been clicked ("cancel" or "share) - the callback function provided doesn't execute.

Tech Stack:

package.json
----dependencies:
--------"@twa-dev/sdk": "^8.0.2",
--------"vue": "^2.7.16",
--------"vue-class-component": "7.2.6",

Telegram.WebApp.version is '9.0'

Using Telegram Desktop on Windows 10. TG version is 5.14.3 x64 with experimental setting "Enable webview inspecting" for console access.

Temporary fix:

WebApp doesn't wrap properly the method. So fix would be accessing Telegram object directly like so:

// @ts-ignore
Telegram.WebApp.requestContact(callback)

Which is not ideal. Please advise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions