| 1234567891011121314151617 |
- import { IOS } from 'cc/env';
- import { IAPImpl, IAPProductsResult, IAPResult } from './IAPImpl';
- import { IOSIAP } from './IOSIAP';
- class UnsupportedIAP extends IAPImpl {
- private unsupported(): never { throw new Error('当前平台尚未实现内购。'); }
- async init(_ids: string[]): Promise<IAPProductsResult> { return this.unsupported(); }
- async purchase(_id: string): Promise<IAPResult> { return this.unsupported(); }
- async restore(): Promise<IAPResult[]> { return this.unsupported(); }
- async getPendingTransactions(): Promise<IAPResult[]> { return this.unsupported(); }
- async finishTransaction(_id: string): Promise<void> { this.unsupported(); }
- onTransaction(_listener: (transaction: IAPResult) => void): () => void { return () => {}; }
- }
- const iap: IAPImpl = IOS ? new IOSIAP() : new UnsupportedIAP();
- export default iap;
- export * from './IAPImpl';
|