API Reference
Registration schema
exports['amzn_smartphone']:registerApp({
id = 'myapp', -- required, [a-z0-9_], max 32 chars
label = 'My App', -- required, display name
icon = 'fa-star', -- required, Font Awesome solid icon
color = '#0a84ff', -- required, hex or CSS gradient
category = 'appstore', -- 'appstore' | 'default'
ui = 'web/index.html', -- required, path in your resource files
description = '', -- optional, App Store text
version = '1.0.0', -- optional
developer = 'My Server', -- optional
})Returns ok, reason on failure (reserved_id, ui_missing, default_not_allowed, etc.).
Category rules
| Category | Behavior |
|---|---|
appstore |
Appears in App Store; must be installed by the player |
default |
Always visible on home screen; requires Config.AllowedDefaultApps[ id ] = true |
Built-in app ids cannot be reused.
Injected iframe globals
Provided by 919phone-sdk.js:
| Global | Description |
|---|---|
resourceName |
Registering resource name |
appName |
Registered app id |
settings |
Phone settings snapshot (theme, brightness, volume) |
fetchNui(event, data) |
Call your resource's RegisterNUICallback handlers |
onNuiEvent(type, callback) |
Listen for phone → app push messages |
onSettingsChange(callback) |
Fired when phone settings change while app is open |
fetchNui
const result = await fetchNui('getData', { page: 1 })
await fetchNui('save', payload)Flow:
- iframe posts to phone shell
- phone validates the app is currently open
- phone calls
https://{registering_resource}/{event}against yourRegisterNUICallback - response resolves the promise
Requests and responses are limited by Config.Sdk.MaxFetchPayload.
sendAppMessage / onNuiEvent
Client export
exports['amzn_smartphone']:sendAppMessage(appId, type, data)Server export
exports['amzn_smartphone']:sendAppMessage(source, appId, type, data)Only the resource that registered the app can send messages for that app.
UI listener
onNuiEvent('refresh', (data) => { ... })
onNuiEvent('route', (params) => { ... })If Config.Sdk.QueueMessagesWhenClosed = true, the latest message per app is delivered on next open.
unregisterApp
exports['amzn_smartphone']:unregisterApp('myapp')Only the registering resource can unregister its own app. Apps are also removed automatically on resource stop.
Config
See Config.Sdk and Config.AllowedDefaultApps in Configuration.