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 { return this.unsupported(); } async purchase(_id: string): Promise { return this.unsupported(); } async restore(): Promise { return this.unsupported(); } async getPendingTransactions(): Promise { return this.unsupported(); } async finishTransaction(_id: string): Promise { this.unsupported(); } onTransaction(_listener: (transaction: IAPResult) => void): () => void { return () => {}; } } const iap: IAPImpl = IOS ? new IOSIAP() : new UnsupportedIAP(); export default iap; export * from './IAPImpl';