App Methods (Native Features)
App methods are methods that access device and platform features.
getInfo
Gets the current user's information.
const user = await gameTegra.getInfo()
console.log(user)
// {
// id: "user-123",
// name: "John",
// surname: "Doe",
// email: "john@example.com",
// age: 25,
// avatar: "https://..."
// }var user = await gameTegra.getUserInfo();
Debug.Log($"Name: {user.name}, Surname: {user.surname}");var user = await gameTegra.getUserInfo()
print("Name: ", user["name"])Return Type:
| Field | Type | Description |
|---|---|---|
| id | string | User's unique ID |
| name | string | First name |
| surname | string | Last name |
| string | Email address | |
| age | number | Age |
| avatar | string | Profile picture URL |
getLanguage
Gets the app and device language information.
const lang = await gameTegra.getLanguage()
console.log(lang)
// {
// language: "en",
// appLanguage: "en",
// deviceLanguage: "en-US"
// }var lang = await gameTegra.getLanguage();
Debug.Log($"Language: {lang.language}, App: {lang.appLanguage}");var lang = await gameTegra.getLanguage()
print("Language: ", lang["language"])Return Type:
| Field | Type | Description |
|---|---|---|
| language | string | Active language code |
| appLanguage | string | App language |
| deviceLanguage | string | Device language |
getLocation
Gets the device's GPS location.
const location = await gameTegra.getLocation()
console.log(location)
// { latitude: 41.0082, longitude: 28.9784, ... }var location = await gameTegra.getLocation();var location = await gameTegra.getLocation()Note: Requires location permission. The user will be prompted for permission.
getParams
Gets app parameters. The mini app's launch parameters are retrieved via this method.
const params = await gameTegra.getParams()
console.log(params)
// { gameId: "abc", mode: "tournament", ... }var params = await gameTegra.getParams();var params = await gameTegra.getParams()camera
Opens the device's camera and returns the captured image.
const photo = await gameTegra.openCamera()var photo = await gameTegra.openCamera();var photo = await gameTegra.openCamera()Note: Requires camera permission.
getImage
Opens the device's gallery and returns the selected image.
const image = await gameTegra.openGallery()var image = await gameTegra.openGallery();var image = await gameTegra.openGallery()Note: Requires gallery permission.
pay
Initiates a payment.
const result = await gameTegra.pay({ amount: 100 })var result = await gameTegra.pay(
gameTegra.@params("amount", 100)
);# As dictionary
var result = await gameTegra.pay({ "amount": 100 })
# or directly as number
var result = await gameTegra.pay(100)Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| amount | number | Yes | Payment amount |
| ... | any | No | Other supported parameters |
vibrate
Vibrates the device. Fire-and-forget: does not wait for a result.
gameTegra.vibrate()gameTegra.vibrate();gameTegra.vibrate()showLoading / hideLoading
Shows/hides the loading indicator. Fire-and-forget.
gameTegra.showLoading()
// When done
gameTegra.hideLoading()gameTegra.showLoading();
// When done
gameTegra.hideLoading();gameTegra.showLoading()
# When done
gameTegra.hideLoading()openMiniApp
Opens another mini app.
const result = await gameTegra.openMiniApp({ miniapp: 'other-game-id' })await gameTegra.openMiniApp(
gameTegra.@params("miniapp", "other-game-id")
);var result = await gameTegra.openMiniApp({ "miniapp": "other-game-id" })Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| miniapp | string | Yes | ID of the mini app to open |
searchMiniapps
Searches for mini apps.
const results = await gameTegra.searchMiniapps('puzzle')var results = await gameTegra.searchMiniApps("puzzle");var results = await gameTegra.searchMiniapps("puzzle")Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | Search query |
reportEvent
Reports an analytics event.
await gameTegra.reportEvent({
eventType: 'level_complete',
data: { level: 5, score: 9500, time: 120 }
})await gameTegra.reportEvent("level_complete",
gameTegra.@params("level", 5, "score", 9500, "time", 120)
);var result = await gameTegra.reportEvent("level_complete", {
"level": 5,
"score": 9500,
"time": 120
})Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| eventType | string | Yes | Event type/name |
| data | object | No | Additional data to send with the event |