{"id":28583412,"url":"https://github.com/scerio/usedesk.dart","last_synced_at":"2025-09-02T06:34:01.821Z","repository":{"id":61975000,"uuid":"465952393","full_name":"ScerIO/usedesk.dart","owner":"ScerIO","description":"Pure dart SDK implementation of usedesk.ru ","archived":false,"fork":false,"pushed_at":"2022-08-16T01:02:40.000Z","size":268,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T05:08:15.614Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScerIO.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-04T02:18:12.000Z","updated_at":"2022-03-06T22:32:09.000Z","dependencies_parsed_at":"2022-10-24T13:45:29.479Z","dependency_job_id":null,"html_url":"https://github.com/ScerIO/usedesk.dart","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ScerIO/usedesk.dart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScerIO%2Fusedesk.dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScerIO%2Fusedesk.dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScerIO%2Fusedesk.dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScerIO%2Fusedesk.dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScerIO","download_url":"https://codeload.github.com/ScerIO/usedesk.dart/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScerIO%2Fusedesk.dart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273244306,"owners_count":25070958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-11T05:08:12.015Z","updated_at":"2025-09-02T06:34:01.769Z","avatar_url":"https://github.com/ScerIO.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# usedesk\r\n\r\nPure dart SDK implementation of usedesk.com service\r\nNow added only `UsedeskChat` sdk \r\n\r\n[![pub package](https://img.shields.io/pub/v/usedesk.svg)](https://pub.dev/packages/usedesk)\r\n\r\n## Getting Started\r\n\r\nIn Example dir fully flutter chat integration with package `flutter_chat_ui`\r\n\r\nIntegrate anywhere by steps:\r\n\r\n1. Need implement token storage, example with shared_preferences:\r\n```dart\r\nimport 'package:shared_preferences/shared_preferences.dart';\r\nimport 'package:usedesk/usedesk.dart';\r\n\r\nclass SharedPreferencesUsedeskChatStorage extends UsedeskChatStorageProvider {\r\n  SharedPreferencesUsedeskChatStorage(this.prefs);\r\n  final SharedPreferences prefs;\r\n\r\n  @override\r\n  Future\u003cString?\u003e getToken() async {\r\n    return prefs.getString('token');\r\n  }\r\n\r\n  @override\r\n  Future\u003cvoid\u003e setToken(String token) {\r\n    return prefs.setString('token', token);\r\n  }\r\n\r\n  @override\r\n  Future\u003cvoid\u003e clearToken() {\r\n    return prefs.remove('token');\r\n  }\r\n}\r\n```\r\n2. Initialize chat\r\n```dart\r\nfinal usedeskChat = await UsedeskChat.init(\r\n    /* Required */\r\n    storage: SharedPreferencesUsedeskChatStorage(prefs),\r\n    companyId: companyId,\r\n\r\n    /* Optional */\r\n    channelId: channelId,\r\n    apiConfig: const ChatApiConfiguration(\r\n        urlChat: 'https://pubsubsec.usedesk.ru',\r\n        urlOfflineForm: 'https://secure.usedesk.ru/',\r\n        urlToSendFile: 'https://secure.usedesk.ru/uapi/v1/send_file',\r\n    ),\r\n);\r\n```\r\n3. Identify client / pass additional data\r\n```dart\r\nusedeskChat\r\n  ..identify = IdentifyConfiguration(\r\n      /* All params optional */\r\n      name: 'Serge Shkurko',\r\n      email: 'mySuper@email.com',\r\n      phoneNumber: 88005553535,\r\n      additionalId: 'uuid_in_my_system',\r\n  )\r\n  ..additionalFields = { \r\n    '99999': 'v$appVersion:$appBuildNumber' \r\n  };\r\n```\r\n4. Subscribe on messages stream\r\n```dart\r\nusedeskChat.messagesStream.listen((List\u003cMessageBase\u003e message) { \r\n    MessageBase message = message.first;\r\n\r\n    final isMyMessage = message is MessageFromClient;\r\n\r\n    // Work with different messages\r\n    if (message is MessageTextBase) {\r\n        print(message.text);\r\n    } else if (message is MessageImageBase) {\r\n        print(message.file);\r\n    } else if (message is MessageFileBase) {\r\n        print(message.file);\r\n    }\r\n});\r\n\r\n\r\n```\r\n5. Control connection\r\n```dart\r\nusedeskChat.connect(); // for receiving usedesk messages from socket\r\n\r\nusedeskChat.disconnect(); // dismiss connection \r\n```\r\n6. Send message\r\n```dart\r\n// Text\r\nusedeskChat.sendText('My cool message');\r\n\r\n// File\r\nusedeskChat.sendFile('My_cool_image.jpg', fileBytes);\r\n```\r\n\r\n## Contributing \r\n\r\nRebuild code generation tools\r\n```bash\r\n# One time run \r\ndart pub run build_runner build --delete-conflicting-outputs\r\n\r\n# Watching of file changes\r\ndart pub run build_runner watch --delete-conflicting-outputs\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscerio%2Fusedesk.dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscerio%2Fusedesk.dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscerio%2Fusedesk.dart/lists"}