fix: 接入抖音原生支付并修复App支付服务缺失
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { UIApplication } from 'UIKit'
|
||||
import { URL, NSUserActivity } from 'Foundation'
|
||||
import { InitOptions, PayOptions, PayCallback } from '../interface.uts'
|
||||
import { configure, invoke } from '../common.uts'
|
||||
|
||||
export function initDypay(options: InitOptions): boolean {
|
||||
if (options.callbackScheme.trim().length == 0 || !configure(options.appId)) return false
|
||||
TbDouyinPayNative.initialize(options.appId, options.callbackScheme, options.universalLink ?? '')
|
||||
return true
|
||||
}
|
||||
|
||||
export function canOpenDypay(): boolean {
|
||||
return TbDouyinPayNative.available()
|
||||
}
|
||||
|
||||
export function openDypay(options: PayOptions, callback: PayCallback): void {
|
||||
invoke(options, callback, (payload: string, loading: boolean, done: (raw: string) => void) => {
|
||||
TbDouyinPayNative.pay(payload, done)
|
||||
})
|
||||
}
|
||||
|
||||
export class TbDouyinPayHook implements UTSiOSHookProxy {
|
||||
applicationOpenURLOptions(app: UIApplication | null, url: URL,
|
||||
options: Map<UIApplication.OpenURLOptionsKey, any> | null = null): boolean {
|
||||
return TbDouyinPayNative.processURL(url)
|
||||
}
|
||||
|
||||
applicationContinueUserActivityRestorationHandler(application: UIApplication | null,
|
||||
userActivity: NSUserActivity | null,
|
||||
restorationHandler: ((res: [any] | null) => void) | null = null): boolean {
|
||||
if (userActivity == null) return false
|
||||
return TbDouyinPayNative.processActivity(userActivity!)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user