77 lines
2 KiB
TypeScript
77 lines
2 KiB
TypeScript
import { WebPlugin } from '@capacitor/core';
|
|
|
|
import type {
|
|
AdUnitOptions,
|
|
ConsentOptions,
|
|
InitOptions,
|
|
InitResult,
|
|
IsReadyResult,
|
|
LevelPlayPlugin,
|
|
MetaDataOptions,
|
|
ShowResult,
|
|
TrackingResult,
|
|
} from './definitions';
|
|
|
|
/**
|
|
* Web stub. LevelPlay has no web SDK: init rejects with `unimplemented`, ads are never ready and every show resolves
|
|
* as "not shown" so callers can treat the web like a no-fill platform without special casing.
|
|
*/
|
|
export class LevelPlayWeb extends WebPlugin implements LevelPlayPlugin {
|
|
private static readonly NO_FILL: ShowResult = {
|
|
shown: false,
|
|
rewarded: false,
|
|
error: { code: -1, message: 'LevelPlay is not available on the web' },
|
|
};
|
|
|
|
async initialize(_options: InitOptions): Promise<InitResult> {
|
|
throw this.unimplemented('LevelPlay is not available on the web.');
|
|
}
|
|
|
|
async getSdkVersion(): Promise<InitResult> {
|
|
return { sdkVersion: 'web' };
|
|
}
|
|
|
|
async setConsent(_options: ConsentOptions): Promise<void> {
|
|
/* nothing to forward */
|
|
}
|
|
|
|
async setMetaData(_options: MetaDataOptions): Promise<void> {
|
|
/* nothing to forward */
|
|
}
|
|
|
|
async requestTrackingAuthorization(): Promise<TrackingResult> {
|
|
return { status: 'unavailable' };
|
|
}
|
|
|
|
async getTrackingAuthorizationStatus(): Promise<TrackingResult> {
|
|
return { status: 'unavailable' };
|
|
}
|
|
|
|
async loadRewarded(_options: AdUnitOptions): Promise<void> {
|
|
/* never fills */
|
|
}
|
|
|
|
async showRewarded(_options: AdUnitOptions): Promise<ShowResult> {
|
|
return { ...LevelPlayWeb.NO_FILL };
|
|
}
|
|
|
|
async loadInterstitial(_options: AdUnitOptions): Promise<void> {
|
|
/* never fills */
|
|
}
|
|
|
|
async showInterstitial(_options: AdUnitOptions): Promise<ShowResult> {
|
|
return { ...LevelPlayWeb.NO_FILL };
|
|
}
|
|
|
|
async isReady(): Promise<IsReadyResult> {
|
|
return { ready: false };
|
|
}
|
|
|
|
async launchTestSuite(): Promise<void> {
|
|
throw this.unimplemented('LevelPlay is not available on the web.');
|
|
}
|
|
|
|
async validateIntegration(): Promise<void> {
|
|
/* nothing to validate */
|
|
}
|
|
}
|