@Eason For more guidance, refer to the documentation here.
Frequently Used Functions
Retrieve the Current User's Device Fingerprint: GetDeviceId()
First, import this function from the SDK:
import { GetDeviceId } from 'ton-ai-sdk'
Invoke this function after the page has finished rendering, such as within a useEffect
hook. (If your project employs server-side rendering, ensure that this function is invoked on the client side.)
useEffect(() => {
const deviceId = GetDeviceId()
console.log('deviceId = ', deviceId)
}, [])
Retrieve the Current User's Telegram User Info: GetTelegramUserInfo()
Begin by importing the function from the SDK:
import { GetTelegramUserInfo } from 'ton-ai-sdk'
Again, call this function post-render, for instance, in a useEffect
hook. Make sure it's executed on the client side if server-side rendering is being used.
useEffect(() => {
const tgUser = GetTelegramUserInfo()
console.log('tgUser = ', tgUser)
}, [])