Development tool: DevEco Studio Integration method: Gradle online integration
Preparation before integration
Registering an account <br>Before using ShareSDK, you need to register a developer account on the MobTech official website and obtain the AppKey and AppSecret provided by Mob. For details, you can click to view the registration process
Social Platform Registration <br>Before using ShareSDK, you need to register, review and obtain a Key on the third-party social platform you need to use. Due to the different requirements of different social platforms, it will not be displayed here.
Add configuration <br>Register MobSDK in project Gradle file
buildscript {
repositories {
// 1.添加MobSDK Maven地址
maven {
url "https://mvn.mob.com/android"
}
...
}
dependencies {
...
// 2.注册MobSDK
classpath 'com.mob.hossdk:MobSDK:+'
}
}
Add plugins and extensions to the Gradle file of the project App Module
apply plugin: 'com.mob.hossdk'
MobSDK {
appKey "xxxxxx"
appSecret "xxxxxxxxxxxx"
ShareSDK {
devInfo {
//目前只支持微信好友、微信朋友圈、微信收藏、QQ、QQ空间、新浪微博
Wechat {
id 4
sortId 4
appId "xxxxxx"
appSecret "xxxxxxxxxxxx"
withShareTicket true
bypassApproval false
enable true
}
WechatMoments {
id 5
sortId 5
appId "xxxxxx"
appSecret "xxxxxxxxxxxx"
bypassApproval false
enable true
}
WechatFavorite {
id 6
sortId 6
appId "xxxxxx"
appSecret "xxxxxxxxxxxx"
bypassApproval false
enable true
}
QQ {
id 7
sortId 7
appId "xxxxxx"
appKey "xxxxxxxxxxxx"
shareByAppClient true
bypassApproval false
enable true
}
}
}
}
Other configuration items
devInfo under ShareSDK currently only supports:
Returns the user privacy authorization result (submitPolicyGrantResult)
//MobSDK.class
/**
* 回传用户隐私授权结果
* @param isGranted 用户是否同意隐私协议
* @param callback 接口执行结果,可为null
*/
public static void submitPolicyGrantResult(boolean isGranted, com.mob.OperationCallback callback)
The developer can specify the calling location of the sample code by himself, just call it before using the SDK function.
MobSDK.submitPolicyGrantResult(true, null);
API interface and sample code
There is no difference between the Hongmeng version API interface of ShareSDK and the native Android API interface. You can refer to the link for testing. The following example uses WeChat to share url pictures:
Platform platform = ShareSDK.getPlatform(Wechat.NAME);
Platform.ShareParams shareParams = new Platform.ShareParams();
shareParams.setImageUrl("https://www.tfkjy.cn/scskx/image/20200611/ae7a53f681e538ea4e132f0d9419ccdc.jpg?download=0");
shareParams.setShareType(Platform.SHARE_IMAGE);
platform.setPlatformActionListener(null);
platform.share(shareParams);
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。