
@anycade/sdk
Web SDK for Anycade Games
Installation
npm i @anycade/sdk
yarn add @anycade/sdk
pnpm add @anycade/sdk
Installation using CDN
Warning
The script must be inserted before your main game script!
<script src="https://unpkg.com/@anycade/sdk@0.0.3/dist/browser/index.min.js"></script>
Getting started
import { SDK } from '@anycade/sdk';
const sdk = new SDK({
gameId: '123456'
});
Using the CDN version, the SDK class is accessible through Anycade.
const sdk = new Anycade.SDK({
gameId: '123456'
});
SDK options
debug - Debug mode
gameId - Game ID
initialize
SDK initialization with the platform.
const sdk = new SDK({
gameId: '123456',
});
try {
await sdk.initialize();
} catch (error) {
}
Payments
purchase
Show the payment window.
try {
const result = await sdk.payments.purchase({
meta: {
foo: 'bar',
},
productId: '123456',
});
switch (result.status) {
case 'cancel':
case 'fail':
case 'success':
}
result.meta;
} catch (error) {
}