share static method
void
share(
分享到渠道 installCallBack :调用端的是否安装成功需要判断 successCallBack :分享成功之后的回调 errorCallBack :出现error回调
Implementation
static void share(
ShareParamsBean shareParamsBean,
PlatformCallback notInstallCallBack,
successCallBack,
errorCallBack) async {
// 首先判断应用是否安装
if (shareParamsBean.platform != SharePlatforms.native) {
bool isInstalled = await isClientInstalled(shareParamsBean.platform);
if (!isInstalled) {
notInstallCallBack(shareParamsBean.platform.id);
return;
}
}
await _channel
.invokeMethod("share", shareParamsBean.toChannelMap())
.then((response) {
if (response["isShareSuccess"] && successCallBack != null) {
successCallBack();
} else {
debugPrint(
'share error errorCode ${response['errorCode']} errorMessage ${response['errorMessage']}');
if (errorCallBack != null) {
errorCallBack(
response["errorCode"] ?? ShareErrorCode.ERROR_BEFORE_JUMP,
response["errorMessage"]);
}
}
}).catchError((error) {
debugPrint('share error ${error.toString()}');
if (errorCallBack != null) {
errorCallBack(ShareErrorCode.ERROR_BEFORE_JUMP);
}
});
}