Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with SetTdlibParameters #2

Closed
aarondiazr opened this issue Jul 9, 2019 · 3 comments
Closed

Problem with SetTdlibParameters #2

aarondiazr opened this issue Jul 9, 2019 · 3 comments
Labels

Comments

@aarondiazr
Copy link

I have a problem when I use SetTdlibParameters event to TDLib, the log show the following:

V/DartMessenger( 7563): Deferring to registered handler to process message.
I/DLTD ( 7563): [ 3][t16][1562713141.231503248][Td.cpp:4380][#4][!Td][&td_requests] Sending update: updateOption {
I/DLTD ( 7563): name = "version"
I/DLTD ( 7563): value = optionValueString {
I/DLTD ( 7563): value = "1.4.0 @tryexceptpass neo"
I/DLTD ( 7563): }
I/DLTD ( 7563): }
I/DLTD ( 7563): [ 3][t16][1562713141.232669115][Td.cpp:4380][#4][!Td][&td_requests] Sending update: updateAuthorizationState {
I/DLTD ( 7563): authorization_state = authorizationStateWaitTdlibParameters {
I/DLTD ( 7563): }
I/DLTD ( 7563): }
I/flutter ( 7563): 3551649040
V/DartMessenger( 7563): Received message from Dart over channel 'channel/to/tdlib'
V/DartMessenger( 7563): Deferring to registered handler to process message.
E/DLTD ( 7563): [ 1][t 0][1562713141.235162973][ClientJson.cpp:67] Failed to parse [request:{@type: setTdlibParameters, parameters: {@type: tdlibParameters, use_test_dc: null, database_directory: null, files_directory: null, use_file_database: null, use_chat_info_database: null, use_message_database: null, use_secret_chats: null, api_id: 111111, api_hash: 2b0650575da164175acd11d17a05e5d8, system_language_code: null, device_model: null, system_version: null, application_version: null, enable_storage_optimizer: null, ignore_file_names: null}, @extra: null}] [Error : 0 : Opening '"' expected]

My example code is:

import 'package:flutter/material.dart';
import 'package:tdlib/client.dart';
import 'package:tdlib/tdapi.dart' as tdapi;
import 'dart:convert';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Telegram Cloud'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  int clientId = 0;
  Client client = Client();

  void getValueMethod(var valor){
    print(valor);
  }

  void _clientCreator() async {
    /*
     Here we renew!
   */
  tdapi.TdlibParameters params = new tdapi.TdlibParameters();
      params.apiId = 111111;
    params.apiHash =  "2b0650575da2b0650575da2b0650575da";
    int newClientId = await client.createClient();
    print(newClientId);
    client.clientSend(newClientId, new tdapi.SetTdlibParameters(parameters: params));
    setState(() {
      clientId = newClientId;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'TDLib Client ID\n$clientId',
            ),
            Text(
              '',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _clientCreator,
        tooltip: 'creator',
        child: Icon(Icons.cached),
      ),
    );
  }
}

Only work if execute clientIdgenerator, but with authorization events doesn´t work.

Thanks for your work, its a good project!

@i-Naji i-Naji added the bug label Jul 11, 2019
@i-Naji i-Naji closed this as completed in a617460 Jul 11, 2019
@nullhandler
Copy link

@aarondiazr how did you get the tdlib log in terminal? I cant get the tdlib logs in terminal.

@aarondiazr
Copy link
Author

@aarondiazr how did you get the tdlib log in terminal? I cant get the tdlib logs in terminal.

I use VSCode, when you launch a flutter project from debug you will access to see logs in general, including tdlib (this library show outputs for default)

Captura de Pantalla 2019-07-17 a la(s) 11 28 32

@nullhandler
Copy link

@aarondiazr thanks man. You developed any sample app with this library?

owenthereal added a commit to owenthereal/tdlib that referenced this issue Aug 26, 2020
Generated fields can be null and this adds null check. An example
exception is:

```
I/flutter ( 6168): NoSuchMethodError: The method 'toJson' was called on null.
I/flutter ( 6168): Receiver: null
I/flutter ( 6168): Tried calling: toJson()
I/flutter ( 6168): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I/flutter ( 6168): i-Naji#1      Message.toJson (package:tdlib/src/tdapi/objects/message.dart:120:42)
I/flutter ( 6168): i-Naji#2      UpdateNewMessage.toJson (package:tdlib/src/tdapi/objects/update.dart:310:31)
I/flutter ( 6168): i-Naji#3      TelegramService._onEvent (package:tdlib_example/services/telegram_service.dart:90:32)
I/flutter ( 6168): i-Naji#4      _rootRunUnary (dart:async/zone.dart:1198:47)
I/flutter ( 6168): i-Naji#5      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
I/flutter ( 6168): i-Naji#6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
I/flutter ( 6168): i-Naji#7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
I/flutter ( 6168): i-Naji#8      _DelayedData.perform (dart:async/stream_impl.dart:611:14)
I/flutter ( 6168): i-Naji#9      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
I/flutter ( 6168): i-Naji#10     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:687:7)
I/flutter ( 6168): i-Naji#11     _rootRun (dart:async/zone.dart:1182:47)
I/flutter ( 6168): i-Naji#12     _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter ( 6168): i-Naji#13     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
I/flutter ( 6168): i-Naji#14     _CustomZone.bindCallbackGuarded.<ano
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants