dingtalk_kit 1.0.4
dingtalk_kit: ^1.0.4 copied to clipboard
DingTalk sharing and authorization plugin for Flutter, with Android, iOS and OHOS implementations and typed response streams.
dingtalk_kit #
Local DingTalk Flutter plugin used by this repository's social_kit, with Android, iOS and OHOS implementations. 中文说明
Publishing #
Run ./tool/publish.sh --dry-run for release checks, or ./tool/publish.sh to check and upload to pub.dev. See PUBLISHING.md for account setup, versioning and archive contents.
Local integration #
The following path is relative to social_kit/pubspec.yaml. Adjust it for another host, or depend on social_kit.
dependencies:
dingtalk_kit:
path: ./plugins/dingtalk_kit
import 'package:dingtalk_kit/dingtalk_kit.dart';
await DingtalkKit.registerApp('YOUR_DINGTALK_APP_ID', 'YOUR_IOS_BUNDLE_ID');
await DingtalkKit.sendTextMessage('Hello');
Compatibility and behavior #
The package is dingtalk_kit, the native registration class is DingtalkKitPlugin, and the Android namespace is com.dingtalk.kit. The Dart API is DingtalkKit and all three platforms use the dingtalk_kit channel. Update callers and rebuild native artifacts together; old native binaries cannot be mixed with the new Dart API. Android writes registrations to the new preference store and falls back to the legacy key only to migrate an existing registration during a cold-start callback. Upstream author and repository metadata in the Podspec identify the original source.
All three platforms support registration, installation checks, opening DingTalk, and text, webpage and image sharing. OHOS returns false for SSO checks and authorization, and an empty string for openAPIVersion. Music and video sharing are not implemented.
A successful send result means the SDK accepted dispatch; it does not confirm that the user sent the message. Native responses arrive through responseStream. Cancel subscriptions when no longer needed.
iOS image sharing uses picUrl. OHOS requires a local path or file:// URI; social_kit downloads remote images before dispatch.
SDK method naming #
Native operations use Dart methods: openAPIVersion(), isDingTalkInstalled(), isDingTalkSupportSSO() and openDingTalk(). The response stream remains a getter.
Android and OHOS use isDDAppInstalled / openDDApp; iOS uses isDingTalkInstalled / openDingTalkOnCompletion:. The Dart API keeps consistent DingTalk names while native handlers follow their platform SDK. Authorization and media sharing methods remain typed wrappers around SDK request objects and sendReq (or Android sendReqToDing).
See the platform mapping. openAPIVersion() retains its existing platform-specific meaning: Android returns the authorization request's protocol version, iOS returns openAPIVersion, and OHOS returns an empty string.
Response models #
Import package:dingtalk_kit/response/dingtalk_response.dart for the response types. DingtalkKit.responseStream is a broadcast Stream<DingtalkResponse> emitting DingtalkShareResponse or DingtalkAuthResponse.
Common properties are errorCode, errorMessage, transaction and isSuccessful. Share responses add type; authorization responses add code and state. DingtalkErrorCode.ERR_* retains the SDK values 0 through -5.
The native payload keys remain errCode, errStr, mTransaction, type, code and state; callback methods remain onShareResponse / onAuthResponse. iOS share responses use integer 2 for type.
Host setup and verification #
Android callback aliases use the host applicationId. On iOS, configure a URL Scheme matching the registered DingTalk App ID and the DingTalk query whitelist. Platform identities must match the DingTalk console configuration.
The plugin requires iOS 12.0 or later; the host must also satisfy its Flutter version's requirements. The local example uses iOS 13.0. See SDK_VERSIONS.md for SDK versions, host requirements and regression commands, and example/README.md for local sample setup.
Run flutter test --no-pub test from the plugin directory to check the Dart channel entry point and response contracts, including the iOS source dictionary. Real sharing, cancellation and return-to-app behavior require device testing.