App Methods
Methods for interacting with the host SuperApp — user info, device features, navigation, and lifecycle.
getInfo
Retrieves the current user's profile information.
gametegra.getInfo()var result = await gametegra.getUserInfo();var result = await gametegra.getUserInfo()Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"name": "player1",
"surname": "",
"email": "player1@example.com",
"age": 28
},
"errorMessage": null
}getLanguage
Returns the app language and the device's system language.
gametegra.getLanguage()var result = await gametegra.getLanguage();var result = await gametegra.getLanguage()Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"appLanguage": "en",
"deviceLanguage": "tr-TR"
},
"errorMessage": null
}getLocation
Gets the device's current GPS location.
gametegra.getLocation()var result = await gametegra.getLocation();var result = await gametegra.getLocation()Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"latitude": 41.0082,
"longitude": 28.9784,
"accuracy": 10
},
"errorMessage": null
}camera
Opens the device camera and returns a base64-encoded JPEG image.
gametegra.camera()var result = await gametegra.openCamera();var result = await gametegra.openCamera()Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"base64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/..."
},
"errorMessage": null
}getImage
Opens the device photo gallery for image selection.
gametegra.getImage()var result = await gametegra.openGallery();var result = await gametegra.openGallery()Response:
{
"onClientSuccess": true,
"onHostSuccess": false,
"data": {
"error": "Do not give consent"
},
"errorMessage": null
}pay
Initiates a payment transaction for the given amount.
gametegra.pay(100)var result = await gametegra.pay(100);var result = await gametegra.pay(100)Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Amount to charge in the app's currency unit. |
Response:
{
"onClientSuccess": true,
"onHostSuccess": false,
"data": {
"error": "Do not give consent"
},
"errorMessage": null
}getParams
Retrieves a launch parameter passed to the miniapp by key.
gametegra.getParams('gameId')var result = await gametegra.getParams();var result = await gametegra.getParams()Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The parameter key to look up. |
Response:
{
"onClientSuccess": true,
"onHostSuccess": false,
"data": {
"error": "Parameter not found"
},
"errorMessage": null
}openMiniApp
Opens another miniapp by its ID and returns the new session ID.
gametegra.openMiniApp('2037673912111730688')await gametegra.openMiniApp("2037673912111730688");var result = await gametegra.openMiniApp('2037673912111730688')Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
miniAppId | string | Yes | The target miniapp's unique identifier. |
Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"sessionId": "1774982421631322"
},
"errorMessage": null
}searchMiniapps
Searches available miniapps by a text query.
gametegra.searchMiniapps('tavla')var result = await gametegra.searchMiniapps("tavla");var result = await gametegra.searchMiniApps('tavla')Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search term. Use at least 4 characters to avoid native errors. |
Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"results": [
{
"id": "1966424934443913216",
"name": "tavla",
"score": 1
},
{
"id": "2025032671452729344",
"name": "Tavla",
"description": "Tavla oyunu",
"logo_url": "http://developer.supergamefy.com/api/MiniApp/2025032671452729344/logo.png",
"category_names": [
"Strategy"
],
"score": 0.6666667
}
]
},
"errorMessage": null
}reportEvent
Reports a custom analytics event with arbitrary data.
gametegra.reportEvent({ eventType: 'level_complete', data: { level: 5, score: 1200 } })await gametegra.reportEvent("level_complete", new Dictionary<string,object>{ {"level",5},{"score",1200} });var result = await gametegra.reportEvent('level_complete', { 'level': 5, 'score': 1200 })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
eventType | string | Yes | The event type identifier (e.g. 'level_complete'). |
data | object | No | Arbitrary key-value data attached to the event. |
Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"status": "ok"
},
"errorMessage": null
}reportMiniApp
Submits a report or feedback about a user or the miniapp itself.
gametegra.reportMiniApp({ type: 'report', message: 'Cheating', meta: { target_type: 'user', target_user_id: 'user_abc' } })await gametegra.reportMiniApp("report", "Cheating", new Dictionary<string,object>{ {"target_type","user"},{"target_user_id","user_abc"} });var result = await gametegra.reportMiniApp({ 'type': 'report', 'message': 'Cheating', 'meta': { 'target_type': 'user', 'target_user_id': 'user_abc' } })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
type | `string ('report' | 'feedback')` | Yes |
message | string | Yes | Description of the report. |
meta | object | No | Optional metadata. Fields: target_type ('user' |
Response:
{
"onClientSuccess": true,
"onHostSuccess": true,
"data": {
"status": "ok"
},
"errorMessage": null
}callMethod
Calls a custom method exposed by the host app by name.
gametegra.callMethod('getInventory', { userId: '123' })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The custom method name registered on the host. |
params | object | No | Parameters to pass to the method. |
Response:
{
"onClientSuccess": true,
"onHostSuccess": false,
"data": {
"error": "Do not give consent for custom Method"
},
"errorMessage": null
}startStream
Starts listening to a named event stream. Returns an Emitter to subscribe/unsubscribe.
gametegra.startStream('game-events', { filter: 'all' })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
streamName | string | Yes | The name of the stream to subscribe to. |
options | object | No | Optional stream options (e.g. { filter: 'all' }). |
Response:
{
"id": "5371c3c4-8a87-40e8-b13c-4e875d46dd6e",
"stream": "game-events",
"_ended": false
}showLoading
Displays the host app's loading spinner.
gametegra.showLoading()gametegra.showLoading();gametegra.showLoading()hideLoading
Hides the host app's loading spinner.
gametegra.hideLoading()gametegra.hideLoading();gametegra.hideLoading()vibrate
Triggers a haptic vibration on the device.
gametegra.vibrate()gametegra.vibrate();gametegra.vibrate()getSafeAreaInsets
Returns the device's safe area insets (notch, home bar, etc.).
gametegra.getSafeAreaInsets()var insets = gametegra.getSafeAreaInsets();var insets = gametegra.getSafeAreaInsets()Response:
{
"top": 47,
"bottom": 34,
"left": 0,
"right": 0
}close
Completely closes and unmounts the miniapp.
gametegra.close()sendToBackground
Minimizes the miniapp and sends it to the background without closing it.
gametegra.sendToBackground()showMenu
Displays the miniapp's native menu overlay.
gametegra.showMenu()setOrientation
Sets the screen orientation mode.
gametegra.setOrientation({ mode: 'landscape' })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
mode | `string ('portrait' | 'landscape' | 'auto')` |
onBackground
Registers a callback that fires when the miniapp is sent to the background.
gametegra.onBackground(() => { pauseGame() })gametegra.onBackground(() => PauseGame());gametegra.onBackground(func(): pauseGame())Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
callback | function | Yes | Function to call when the app goes to background. |
Response:
"function(){ i.delete(e) }"onForeground
Registers a callback that fires when the miniapp returns to the foreground.
gametegra.onForeground(() => { resumeGame() })gametegra.onForeground(() => ResumeGame());gametegra.onForeground(func(): resumeGame())Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
callback | function | Yes | Function to call when the app returns to foreground. |
Response:
"function(){ i.delete(e) }"