Commit 65d166f7 authored by 郑磊's avatar 郑磊

增加直接发起内购的原生方法

parent e8259324
......@@ -217,3 +217,57 @@ export function openLiveGiftPanel() {
console.log('调用框架方法', 'openLiveGiftPanel')
callNativeApi('openLiveGiftPanel')
}
/**
* 拉起内购的配置项
*/
export interface InAppPurchaseParams {
/**
* 内购标识
*/
productIdentifier: string
/**
* 内购类型
*/
type: string
}
/**
* 内购结果数据
*/
export interface InAppPurchaseResult {
/**
* 内购结果
*/
status: string
/**
* 内购标识
*/
productIdentifier: string
/**
* 后台返回的订单号
*/
orderId: number
}
/**
* 发起内购
* @param params 发起内购的配置项
*/
export function inAppPurchase(params: InAppPurchaseParams) {
return new Promise<InAppPurchaseResult>((resolve) => {
callNativeApi('openLiveGiftPanel', () => {})
const onResult = (result: InAppPurchaseResult) => {
resolve(result)
// @ts-ignore
if (window.onIAPPurchaseResult === onResult) {
// @ts-ignore
delete window.onIAPPurchaseResult
}
}
// @ts-ignore
window.onIAPPurchaseResult = onResult
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment