sending the verification code to the SMS and not to the application

Viewed 763

is it possible to define how the verification code will be sent when calling the LoginUserIfNeeded method? I need to send it via SMS and not to the application.

1 Answers

Telegram servers decide by themselves through which method to send the code initially.

However if the user did not receive the code (eventually after a given timeout), he can request the code to be sent through an alternative method:

In WTelegramClient, this is done by returning an empty string for "verification_code" (typically, only on the first try)

You should probably first check through which medium Telegram sent the code:
The client.OnUpdate event receives a Auth_SentCode object specifying details (type) about the transmitted verification code. Then you can decide to reply the empty string only if it was transmitted through a medium you don't have access to.

If the code was initially sent through the App, Telegram will then likely send the code through SMS instead. (and you can reply an empty verification_code again to request the code to be transmitted via a Phone Call)

Additionally, on the call to LoginUserIfNeeded you can pass a CodeSettings instance which offer some very limited options about the sending of the code.

Related