SDK Functions
onOpenApp(appId, cb)
appId (string): this will be the app unique name
cb (function): this function will be executed when the app is oppened
SDK.onOpenApp('customApp', () => {
console.log('Open APP Event Triggered')
})
onCloseApp(appId, cb)
appId (string): this will be the app unique name
cb (function): this function will be executed when the app is closed
SDK.onCloseApp('customApp', () => {
console.log('Close APP Event Triggered')
})
setContextMenu(buttons)
buttons (array): array of objects that contain the buttons information
title (string): the label of the button
color (string): the button text color
SDK.setContextMenu([
{
title: 'Click ME',
color: 'white',
cb: () => {
console.log('Button clicked')
}
},
])
setPopUp(info)
info (object): element that contains all the information of the popup that will be created
title (string): this is the title of the popup
description (string-optional): this is the description of the popup
input (object-optional): these are the input html attributes
media (string-optional): this is an image or video URL
code (string-optional): this is a big text code
buttons (array): these are the buttons of the popup
title (string): the label of the button
color (string): the color of the button text
cb (function): when a button is clicked, this will be triggered
inputContent (string): this is an attribute that cb returns with the input value
SDK.setPopUp({
title: 'This is the title',
description: 'This is the description',
code: '958',
media: 'https://r2.fivemanage.com/pub/zdlyvumu5gkj.png',
input: {
type: 'text',
placeholder: 'Place your text here',
maxlength: 16
},
buttons: [
{
title: 'Cancel',
color: "#FF3A45",
cb: () => {}
},
{
title: 'Save',
color: "#0A84FF",
cb: (inputContent) => {
console.log(inputContent)
}
}
]
})
fetchNui(fetchName, data, cb, scriptName)
fetchName (string): this is the name of the nui event
data (object): this is the object that is sent to the nui handler
cb (function): this will return the nui data
scriptName (string): this is the script name that you want the nui event
SDK.fetchNui('getCoords', {}, (returnedData) => {
console.log(returnedData)
}, 'my-resource-name')
getSettings(cb)
cb (function): this will return the entire phone settings
SDK.getSettings((settings) => {
console.log(settings)
})
getLocale(locale, cb)
locale (string): this is the name of the locale that you will get
cb (function): this will return the text in the user's language
SDK.getLocale('camera-label', (label) => {
console.log(label)
})
selectGallery(info)
info (object): this is the object containing the information of the gallery created
includeImages (boolean): this will include or exclude images
includeVideos (boolean): this will include or exclude videos
limit (number): this is the limit of selections that the user can do
cb (function): this is will return the images selected by the user
SDK.selectGallery({
includeImages: true,
includeVideos: false,
limit: 3,
cb: (images) => {
console.log(images)
}
})
useCamera(info)
info (object): this will be an object containing all the info regarding to the camera control
defaultConfig (object): this will be the starting settings of the camera
type (string): this is the type of media that the phone will take by default
flash (boolean): this is the default status of the flash
camera (string): this is the default starting camera
permissions (object): this will be the posibilities of the player inside the camera
toggleFlash (boolean): player can toggle flash
flipCamera (boolean): player can flip the camera
takePhoto (boolean): player can take photos
takeVideo (boolean): player can take videos
cb (string): this will return the media URL
SDK.useCamera({
defaultConfig: {
type: 'photo', // photo, video
flash: true,
camera: 'rear', // rear, front
},
permissions: {
toggleFlash: true,
flipCamera: false,
takePhoto: false,
takeVideo: true
},
cb: (url) => {
console.log(url)
}
})
onSettingsChange(cb)
cb (function): this will return the entire phone settings
SDK.onSettingsChange((settings) => {
console.log(settings)
})
isAppInstalled(appId)
appId (string): this is your app unique identifier
const hasAPP = SDK.isAppInstalled('my-app-name')
Last updated