Skip to content

App Methods

Methods for interacting with the host SuperApp — user info, device features, navigation, and lifecycle.

getInfo

Retrieves the current user's profile information.

js
gametegra.getInfo()
csharp
var result = await gametegra.getUserInfo();
gdscript
var result = await gametegra.getUserInfo()

Response:

json
{
  "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.

js
gametegra.getLanguage()
csharp
var result = await gametegra.getLanguage();
gdscript
var result = await gametegra.getLanguage()

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": true,
  "data": {
    "appLanguage": "en",
    "deviceLanguage": "tr-TR"
  },
  "errorMessage": null
}

getLocation

Gets the device's current GPS location.

js
gametegra.getLocation()
csharp
var result = await gametegra.getLocation();
gdscript
var result = await gametegra.getLocation()

Response:

json
{
  "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.

js
gametegra.camera()
csharp
var result = await gametegra.openCamera();
gdscript
var result = await gametegra.openCamera()

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": true,
  "data": {
    "base64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/..."
  },
  "errorMessage": null
}

getImage

Opens the device photo gallery for image selection.

js
gametegra.getImage()
csharp
var result = await gametegra.openGallery();
gdscript
var result = await gametegra.openGallery()

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": false,
  "data": {
    "error": "Do not give consent"
  },
  "errorMessage": null
}

pay

Initiates a payment transaction for the given amount.

js
gametegra.pay(100)
csharp
var result = await gametegra.pay(100);
gdscript
var result = await gametegra.pay(100)

Parameters:

NameTypeRequiredDescription
amountnumberYesAmount to charge in the app's currency unit.

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": false,
  "data": {
    "error": "Do not give consent"
  },
  "errorMessage": null
}

getParams

Retrieves a launch parameter passed to the miniapp by key.

js
gametegra.getParams('gameId')
csharp
var result = await gametegra.getParams();
gdscript
var result = await gametegra.getParams()

Parameters:

NameTypeRequiredDescription
keystringYesThe parameter key to look up.

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": false,
  "data": {
    "error": "Parameter not found"
  },
  "errorMessage": null
}

openMiniApp

Opens another miniapp by its ID and returns the new session ID.

js
gametegra.openMiniApp('2037673912111730688')
csharp
await gametegra.openMiniApp("2037673912111730688");
gdscript
var result = await gametegra.openMiniApp('2037673912111730688')

Parameters:

NameTypeRequiredDescription
miniAppIdstringYesThe target miniapp's unique identifier.

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": true,
  "data": {
    "sessionId": "1774982421631322"
  },
  "errorMessage": null
}

searchMiniapps

Searches available miniapps by a text query.

js
gametegra.searchMiniapps('tavla')
csharp
var result = await gametegra.searchMiniapps("tavla");
gdscript
var result = await gametegra.searchMiniApps('tavla')

Parameters:

NameTypeRequiredDescription
querystringYesSearch term. Use at least 4 characters to avoid native errors.

Response:

json
{
  "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.

js
gametegra.reportEvent({ eventType: 'level_complete', data: { level: 5, score: 1200 } })
csharp
await gametegra.reportEvent("level_complete", new Dictionary<string,object>{ {"level",5},{"score",1200} });
gdscript
var result = await gametegra.reportEvent('level_complete', { 'level': 5, 'score': 1200 })

Parameters:

NameTypeRequiredDescription
eventTypestringYesThe event type identifier (e.g. 'level_complete').
dataobjectNoArbitrary key-value data attached to the event.

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": true,
  "data": {
    "status": "ok"
  },
  "errorMessage": null
}

reportMiniApp

Submits a report or feedback about a user or the miniapp itself.

js
gametegra.reportMiniApp({ type: 'report', message: 'Cheating', meta: { target_type: 'user', target_user_id: 'user_abc' } })
csharp
await gametegra.reportMiniApp("report", "Cheating", new Dictionary<string,object>{ {"target_type","user"},{"target_user_id","user_abc"} });
gdscript
var result = await gametegra.reportMiniApp({ 'type': 'report', 'message': 'Cheating', 'meta': { 'target_type': 'user', 'target_user_id': 'user_abc' } })

Parameters:

NameTypeRequiredDescription
type`string ('report''feedback')`Yes
messagestringYesDescription of the report.
metaobjectNoOptional metadata. Fields: target_type ('user'

Response:

json
{
  "onClientSuccess": true,
  "onHostSuccess": true,
  "data": {
    "status": "ok"
  },
  "errorMessage": null
}

callMethod

Calls a custom method exposed by the host app by name.

js
gametegra.callMethod('getInventory', { userId: '123' })

Parameters:

NameTypeRequiredDescription
namestringYesThe custom method name registered on the host.
paramsobjectNoParameters to pass to the method.

Response:

json
{
  "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.

js
gametegra.startStream('game-events', { filter: 'all' })

Parameters:

NameTypeRequiredDescription
streamNamestringYesThe name of the stream to subscribe to.
optionsobjectNoOptional stream options (e.g. { filter: 'all' }).

Response:

json
{
  "id": "5371c3c4-8a87-40e8-b13c-4e875d46dd6e",
  "stream": "game-events",
  "_ended": false
}

showLoading

Displays the host app's loading spinner.

js
gametegra.showLoading()
csharp
gametegra.showLoading();
gdscript
gametegra.showLoading()

hideLoading

Hides the host app's loading spinner.

js
gametegra.hideLoading()
csharp
gametegra.hideLoading();
gdscript
gametegra.hideLoading()

vibrate

Triggers a haptic vibration on the device.

js
gametegra.vibrate()
csharp
gametegra.vibrate();
gdscript
gametegra.vibrate()

getSafeAreaInsets

Returns the device's safe area insets (notch, home bar, etc.).

js
gametegra.getSafeAreaInsets()
csharp
var insets = gametegra.getSafeAreaInsets();
gdscript
var insets = gametegra.getSafeAreaInsets()

Response:

json
{
  "top": 47,
  "bottom": 34,
  "left": 0,
  "right": 0
}

close

Completely closes and unmounts the miniapp.

js
gametegra.close()

sendToBackground

Minimizes the miniapp and sends it to the background without closing it.

js
gametegra.sendToBackground()

showMenu

Displays the miniapp's native menu overlay.

js
gametegra.showMenu()

setOrientation

Sets the screen orientation mode.

js
gametegra.setOrientation({ mode: 'landscape' })

Parameters:

NameTypeRequiredDescription
mode`string ('portrait''landscape''auto')`

onBackground

Registers a callback that fires when the miniapp is sent to the background.

js
gametegra.onBackground(() => { pauseGame() })
csharp
gametegra.onBackground(() => PauseGame());
gdscript
gametegra.onBackground(func(): pauseGame())

Parameters:

NameTypeRequiredDescription
callbackfunctionYesFunction to call when the app goes to background.

Response:

json
"function(){ i.delete(e) }"

onForeground

Registers a callback that fires when the miniapp returns to the foreground.

js
gametegra.onForeground(() => { resumeGame() })
csharp
gametegra.onForeground(() => ResumeGame());
gdscript
gametegra.onForeground(func(): resumeGame())

Parameters:

NameTypeRequiredDescription
callbackfunctionYesFunction to call when the app returns to foreground.

Response:

json
"function(){ i.delete(e) }"