plutosdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.2-beta.4 • Public • Published

Pluto SDK for Telegram

Getting started

Add the configuration required by sdk, and installation telegram web app sdk with cdn.

Add the script to your HTML file:

<meta name="viewport" content="initial-scale=1, width=device-width" />
<meta name="theme-color" content="#000000" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<script src="https://telegram.org/js/telegram-web-app.js"></script>

Installation pluto sdk with cdn

Add the script inside the body tag of your HTML file:

<script src="https://unpkg.com/plutosdk@latest/dist/pluto-sdk.js"></script>

ℹ️ If you don't want auto-update the library, pass concrete version instead of latest, e.g.

<script src="https://unpkg.com/plutosdk@0.0.1/dist/pluto-sdk.js"></script>

Usage

You can use global variable PlutoSDK

init

PlutoSDK.init()

It returns a promise that resolves after init success.

login

PlutoSDK.login()

It returns a promise that resolves after login success.

ready

PlutoSDK.ready()

This method is called after login is complete. Call this method at the appropriate time to notify the SDK to delete the loading animation.

share

PlutoSDK.share()

This method is shared in telegram.

purchase

PlutoSDK.purchase(name, orderId, amount, customData, callback)

This method accepts the name orderId amount customData callback as parameters. customData and callback are optional parameters. Please note that the this pointer of the callback method callback will be changed.

getShareLink

PlutoSDK.getShareLink()

This method is get share link.

copyShareLink

PlutoSDK.copyShareLink()

This method is copy share link to clipboard.

getItem

PlutoSDK.getItem(key)

This method that receives a value from the server using the specified key. It returns a promise.

setItem

PlutoSDK.setItem(key, value)

This method that stores a value in the server using the specified key. It returns a promise.

Readme

Keywords

none

Package Sidebar

Install

npm i plutosdk

Weekly Downloads

1,780

Version

1.0.2-beta.4

License

none

Unpacked Size

801 kB

Total Files

83

Last publish

Collaborators

  • xupf886