deepshare android,DeepShare Android 集成

DeepShare Android 集成

1. 配置Manifest文件

在应用入口Activity中增加DeepShare的intent-filter,这样APP就可以通过浏览器被唤起。

android:host="此处填写DeepShare配置中显示的host"

android:scheme="此处填写DeepShare配置中显示的scheme" />

2. 启动DeepShare

在应用入口Activity的onStart()中调用如下方法:

ZhugeParam param = new ZhugeParam.Builder()

.appKey("appKey")

.appChannel("channel")

.inAppDataListener(listener)

.did("did")

.build();

ZhugeSDK.getInstance().initWithDeepShareAndParam(activity ,param);

initWithDeepShareAndParam() 初始化SDK和DeepShare功能,并配置启动参数。

参数说明:

参数

说明

activity

应用入口的activity

appKey

官网申请的AppKey

channel

应用分发渠道

listener

用于获取场景还原参数的listener

did

自定义设备ID,长度不超过256个字符

注意:

init() 与initWithDeepShareAndParam()只能调用一个,同时调用会以第一个成功执行的为准。

调用initWithDeepShareAndParam()时,若ZhugeParam中没有配置appKey及appChannel,则会从应用的manifest文件中获取,若找不到appKey及appChannel则初始化失败。

3. 添加启动回调

在启动Activity的onNewIntent处添加如下代码:

@Override

public void onNewIntent(Intent intent) {

this.setIntent(intent);

}

4. 获取场景还原参数

为实现场景还原功能,你需要实现ZhugeInAppDataListener 接口。

ZhugeInAppDataListener接口定义了场景调用成功时的回调函数zgOnInappDataReturned,及失败时的回调函数zgOnFailed。

在初始化SDK时,传入ZhugeInAppDataListener来获取场景还原参数,并通过重写异步回调方法zgOnInappDataReturned()获取分享参数params。

示例代码如下:

public class MainActivity extends Activity {

public void onStart() {

super.onStart();

ZhugeParam param = new ZhugeParam.Builder()

.inAppDataListener(new MyListener())

.build();

ZhugeSDK.getInstance().initWithDeepShareAndParam(this,param);

}

public static class MyListener implements ZhugeInAppDataListener{

@Override

public void zgOnInAppDataReturned(JSONObject initParams) {

Log.e(TAG,"zgOnInAppDataReturned "+initParams.toString());

}

@Override

public void zgOnFailed(String reason) {

}

}

}©zhugeio.com 京ICP备15049545号            文档更新时间 2021-05-11 17:36:19

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值