感谢您的反馈!
名称 |
下载地址 |
使用说明 |
鸿蒙版百川SDK |
需要DevEco Studio 5.0.3.700及以上版本 |
|
手淘测试包 |
需使用鸿蒙unlock机器安装 1. 回归产物HAP、HSP均要下载至电脑本地 2. 非覆盖安装,需要先卸载,再安装HSP、HAP: hdc install hsp路径 hdc install hap路径 |
|
鸿蒙百川接入Demo |
需在工程中,放入申请好的安全图片,把lib目录下替换为最新的鸿蒙百川SDK,按SDK接入步骤替换appKey等配置 |
创建应用
登录https://console.baichuan.taobao.com/applications.htm进行应用创建,使用iOS应用创建流程,Bundle ID填写鸿蒙应用Bundle Name。详细创建流程可参考文档 https://baichuan.taobao.com/docs/doc.htm?treeId=129&articleId=118101&docType=1。
安全图片下载
登录https://suite.baichuan.taobao.com/#/sdk ,选择刚刚创建的应用,进行鸿蒙版安全图片下载,选择v6版本安全图片,文件名为yw_1222.jpg。
AppKey加白
将申请好的appKey提供给百川官方小二,走加白流程,加白后SDK可以正常调用。
加白提交方式可参考对外公告:https://qn.taobao.com/headline/news/10713252?spm=a211vu.12026430.0.0.b46b3929iVukWe
鸿蒙版百川依赖使用集成态hsp对外提供,接入前请先确认接入步骤前两点
{ "module": { ... "abilities": [ { ... "skills": [ { ... "uris": [ { "scheme": "taobaooauth{替换为自身的appKey}" } ] } ] }], "querySchemes": [ "tbopen", "tbaccount34692017" ] } }
/** @param context // 上下文对象 @param onSuccess // 成功回调 @param onFailure // 失败回调 */ export interface AlibcInitOption { context: Context; onSuccess?: () => void onFailure?: (code: number, msg: string) => void }
Alibc.init({ context: this.context, onSuccess: () => { hilog.info(0xF101, 'EntryAbility', 'Alibc init success'); }, onFailure: (code, msg) => { hilog.info(0xF101, 'EntryAbility', 'Alibc init fail code: %{public}d, msg: %{public}s', code, msg); } })
/** @param url // 跳转的url,必传参数 @param onSuccess // 成功回调 @param onFailure // 失败回调 @param showParams // 显示参数 @param taokeParams // 淘客参数 @param trackParams // 跟踪参数 @param needBaichuanLinkConvert // 是否需要百川SDK使用taokeParams对传入链接执行转链,默认不需要 */ export interface AlibcOpenByUrlOption { url: string; onSuccess?: (code: number, msg: string) => void; onFailure?: (code: number, msg: string) => void; showParams?: AlibcShowParams; taokeParams?: AlibcTaokeParams; trackParams?: Map<string, string>; needBaichuanLinkConvert?: boolean; }
let url = 'https://s.click.taobao.com/t?e=m%3D2%26s%3D1DANZtzHz7tw4vFB6t2Z2ueEDrYVVa64XoO8tOebS%2BfLWlSKdGSYDkgknI00BwY1MMgx22UI05ZGtvS2t8YXqql3YCacbAJGs0x9Gq7vDdqeKYIajGjChTpRpDJK%2FklF1RoBZXScntTUEheyLYMGXiU3eodff7ogotYzDcQ4SzIWZKt7NvIcGa1FXqxF%2F3mtXyerTiacefDX6KAEhsqp0hkfaIiVwydT67NJ05nbfGYzgmkCpJbUi2RBwUWWyHogzQ5pNhyIxpdNzuMLUNyvdNqIL1Eu%2F%2FLDsMlV1JGOt%2FN%2FQXu2D%2BXFgcKyIHBZkBMC&relationId=&skuId=5593778439447&union_lens=lensId%3ATAPI%401716084058%40212aafd5_111a_18f8e94aab4_162e%4001&ttid=2014_0_23022129@baichuan_android_5.0.2.1' let showParams: AlibcShowParams = {clientType: 'taobao'} let taokeParams: AlibcTaokeParams = {pid: "mm_26381042_107400144_109668650092"} let needBaichuanLinkConvert = false; Alibc.openByUrl({ url, onSuccess: (code, msg) => { hilog.info(0xF101, 'Index', 'openByUrl成功回调 code: %{public}d, msg: %{public}s', code, msg) }, onFailure: (code, msg) => { hilog.info(0xF101, 'Index', 'openByUrl失败回调 code: %{public}d, msg: %{public}s', code, msg) }, showParams, taokeParams, needBaichuanLinkConvert}) })
onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { Alibc.onNewWant(want); }
/** @param onSuccess // 成功回调 @param onFailure // 失败回调 */ export interface AlibcLoginOption { onSuccess?: (user?: AlibcLoginUser) => void onFailure?: (code: string, msg: string) => void }
Alibc.login({ onSuccess: (user) => { hilog.info(0xF101, 'Index', 'showLogin success user openId %{public}s', user?.openId); }, onFailure: (code, msg) => { hilog.info(0xF101, 'Index', 'showLogin onFail code: %{public}s, msg: %{public}s', code, msg); } })
/** @param onComplete // 登出完成回调 */ export interface AlibcLogoutOption { onComplete?: () => void; }
Alibc.logout({ onComplete: () => { hilog.info(0xF101, 'Index', 'logout'); } });
/** * 调用 authorize 方法前必须调用,否则会导致无法弹出授权浮层 * 设置授权浮层弹出的 windowStage,可在宿主APP的 EntryAbility onWindowStageCreate 回调中调用 * @param windowStage */ onWindowStageCreate(windowStage: window.WindowStage) { Alibc.setAuthorizeWindowStage(windowStage); }
/** @param appName // 用于top授权时展示应用名称 @param appLogoSrc // 用于top授权时展示应用图标 @param appKey // 业务方appkey @param onSuccess // 成功回调 @param onFailure // 失败回调 */ export interface AlibcAuthOption { appName: string; appLogoSrc: Resource; appKey: string; onSuccess?: (params: AlibcAuthOnSuccessParams) => void; onFailure?: (code: string, msg: string) => void; }
Alibc.authorize({ appName: '测试应用', appLogoSrc: $r('app.media.icon'), appKey: Alibc.getAppKey(), onSuccess: (params) => { hilog.info(0xF101, 'Index', 'topAuth success accessToken: %{public}s, expireTime: %{public}s', params.accessToken, params.expireTime); }, onFailure: (code, msg) => { hilog.info(0xF101, 'Index', 'topAuth fail code: %{public}d, msg: %{public}s', code, msg); } });
let appKey = Alibc.getAppKey()
export class AlibcInitCode { static readonly SECURITY_INIT_FAIL = 1000 // 安全保镖初始化失败 static readonly MTOP_INIT_FAIL = 2000 // MTOP初始化失败 static readonly UT_INIT_FAIL = 3000 // UT初始化失败 static readonly LOGIN_INIT_FAIL = 4000 // 登录sdk初始化失败 }
export const SDK_NOT_INIT_CODE = 1000 export const SDK_NOT_INIT_MSG = 'SDK没有初始化' export const NOT_SUPPORT_MINIAPP_CODE = 1300 export const NOT_SUPPORT_MINIAPP_MSG = '不支持小程序链接' export const LAUNCH_SUCCESS_CODE = 2000 export const LAUNCH_SUCCESS_MSG = '唤端成功' export const LAUNCH_NOT_SUPPORT_CLIENT_CODE = 2100 export const LAUNCH_NOT_SUPPORT_CLIENT_MSG = '不支持的唤端类型' export const LAUNCH_FAIL_CODE = 2200 export const LAUNCH_FAIL_MSG = '唤端失败,异常crash' export const LAUNCH_LACK_QUERY_SCHEMES_CODE = 2300 export const LAUNCH_LACK_QUERY_SCHEMES_MSG = '未配置目标scheme' export const LAUNCH_LINK_FAIL_CODE = 2400 export const LAUNCH_LINK_FAIL_MSG = '未找到目标app'
export const AUTH_NOT_INIT = 'AUTH_NOT_INIT'; //在onWindowStageCreate中先调用setAuthorizeWindowStage接口 export const AUTH_UI_ERROR = 'AUTH_UI_ERROR'; //系统createSubWindow创建失败 export const AUTH_NETWORK_ERROR = 'AUTH_NETWORK_ERROR'; //接口请求失败,检查appkey export const AUTH_USER_CANCEL = 'AUTH_USER_CANCEL'; // 用户取消授权 export const AUTH_FREQUENCY_LIMIT = 'AUTH_FREQUENCY_LIMIT' //授权频次过高,时间间隔需大于1秒