Android 接入淘宝百川Sdk

  • 内容
  • 评论
  • 相关

注:如果想实现商品佣金转链需要在阿里妈妈APP管理申请应用获得 pid,推广位名称要与阿里百川创建的App名称相同。相关Api 链接

接入:

程序Gradle导入

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

 

因为在百度渠道不能使用阿里巴巴支付sdk所以这里使用productFlavors {baidu {}other {}}实现多渠道打包。用渠道名称+Compile实现单渠道加载库

    apply plugin: 'com.neenbedankt.android-apt'
    //fastjson
    compile 'com.alibaba:fastjson:1.2.9'
    //支付
    otherCompile 'com.alibaba.alipay:alipaySingle:20160825@jar'
    //登陆
    compile 'com.ali.auth.sdk:alibabauth_core:1.4.3@jar'
    compile 'com.ali.auth.sdk:alibabauth_ui:1.4.3@aar'
    compile 'com.ali.auth.sdk:alibabauth_ext:1.4.3@jar'
    //安全基础
    compile 'com.taobao.android:securityguardaar3:5.1.81@aar'
    //Mtop网关
    compile 'com.taobao.android:mtopsdk_allinone_open:1.2.2.4@jar'
    //applink
    compile 'com.alibaba.sdk.android:alibc_link_partner:1.1.0.0'
    //UT
    //compile 'com.taobao.android:utdid4all:1.1.5.3_proguard@jar'
    compile 'com.alibaba.mtl:app-monitor-sdk:2.5.1.3_for_bc_proguard@jar'
    //联盟SDK
    compile 'com.alimama.tunion.sdk:tuniontradesdk:0.3.2'
    //电商SDK
    compile 'com.alibaba.sdk.android:alibc_trade_common:3.1.1.206'
    compile 'com.alibaba.sdk.android:alibc_trade_biz:3.1.1.206'
    compile 'com.alibaba.sdk.android:alibc_trade_sdk:3.1.1.206'

回调类

public class DemoTradeCallback implements AlibcTradeCallback {

    @Override
    public void onTradeSuccess(AlibcTradeResult tradeResult) {
        //当addCartPage加购成功和其他page支付成功的时候会回调

        if(tradeResult.resultType.equals(AlibcResultType.TYPECART)){
            //加购成功
            Toast.makeText(AliSdkApplication.application, "加购成功", Toast.LENGTH_SHORT).show();
        }else if (tradeResult.resultType.equals(AlibcResultType.TYPEPAY)){
            //支付成功
            Toast.makeText(AliSdkApplication.application, "支付成功,成功订单号为"+tradeResult.payResult.paySuccessOrders, Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onFailure(int errCode, String errMsg) {
        Toast.makeText(AliSdkApplication.application, "电商SDK出错,错误码="+errCode+" / 错误消息="+errMsg, Toast.LENGTH_SHORT).show();
    }
}

//电商SDK初始化

//电商SDK初始化
        AlibcTradeSDK.asyncInit(this, new AlibcTradeInitCallback() {
            @Override
            public void onSuccess() {
                //Toast.makeText(AliSdkApplication.this, "初始化成功", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onFailure(int code, String msg) {
                Toast.makeText(AliSdkApplication.this, "初始化应用失败,错误码="+code+" / 错误消息="+msg, Toast.LENGTH_SHORT).show();
            }
        });

举例:加载商品调用

        alibcTaokeParams = new AlibcTaokeParams(); // 若非淘客taokeParams设置为null即可
        alibcTaokeParams.adzoneid = "136690366";
        alibcTaokeParams.pid = "mm_56584098_37534934_136690366";
        // alibcTaokeParams.subPid = "mm_56584098_37534934_136690366";
        alibcTaokeParams.extraParams = new HashMap<>();
        alibcTaokeParams.extraParams.put("taokeAppkey", "24642765");

 

  public void showGood(){
        AlibcBasePage alibcBasePage = new AlibcDetailPage(goodID);
        AlibcShowParams alibcShowParams = new AlibcShowParams(OpenType.H5, false);
        AlibcTrade.show(AliSdkWebViewProxyActivity.this,webView, webViewClient, webChromeClient,alibcBasePage,alibcShowParams,alibcTaokeParams,exParams, new DemoTradeCallback());
    }

混淆

-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.taobao.** {*;}
-keep class com.alibaba.** {*;}
-keep class com.alipay.** {*;}
-dontwarn com.taobao.**
-dontwarn com.alibaba.**
-dontwarn com.alipay.**
-keep class com.ut.** {*;}
-dontwarn com.ut.**
-keep class com.ta.** {*;}
-dontwarn com.ta.**
-keep class org.json.** {*;}
-keep class com.ali.auth.** {*;}

评论

0条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注