Starting a Telegram API instance

后端 未结 2 1803
迷失自我
迷失自我 2021-02-15 15:55

Hi! Telegram API beginner here! I\'m developing a PhoneGap app that features a messaging service using the Telegram API.

I\'m currently following the API guide

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-15 16:51

    Referencing some documentation in the Git Hub page...

    To create a TelegramApi instance, one must first create a custom implementation of the org.telegram.api.engine.storage.AbsApiState class and implement the suitable methods. An instance of the custom class implementation will then be used as a parameter for the TelegramApi constructor method.

    Example from the Git Hub page:

    TelegramApi api = new TelegramApi(new MyApiStorage(), new AppInfo(/*... put application information here...*/), new ApiCallback()
    {
      @Override
      public void onApiDies(TelegramApi api) {
        // When auth key or user authorization dies
      }
      @Override
      public void onUpdatesInvalidated(TelegramApi api) {
        // When api engine expects that update sequence might be broken  
      }
    });
    

    As for the auth.sendCode method, this method is actually an remote procedure call (RPC), and does not belong to any class in the library. These are methods invoked by the client to be executed by the Telegram server. See the Telegram FAQ regarding TL for more information.

提交回复
热议问题