Compatibility
lb-phone compatibility
What scripts and custom apps written for lb-phone need to run on FX Phone, and which export names carry over.
FX Phone follows lb-phone's PascalCase export names and accepts lb-phone's custom app definition. A script or app written for lb-phone runs on FX Phone in one of two ways:
- Change the resource name. Replace
exports['lb-phone']withexports['fx-phone']in the script's Lua. This is the preferred way for any script you can edit. - Start the shim resource. For scripts you cannot edit (escrowed apps, resources that list
lb-phoneunderdependencies), FX Phone ships an optional resource namedlb-phonethat answersexports['lb-phone']and forwards every call to FX Phone.
lua-- before
exports['lb-phone']:SendNotification({ app = 'garage', title = 'Garage', content = 'Vehicle delivered.' })
-- after
exports['fx-phone']:SendNotification({ app = 'garage', title = 'Garage', content = 'Vehicle delivered.' })
FX Phone itself registers nothing under the lb-phone resource name. Only the shim does.
#What works without changes
| Area | Behaviour |
|---|---|
| Export names | The names in the tables below exist on exports['fx-phone'] with the same name. |
| Custom app definition | AddCustomApp reads lb-phone's fields: identifier, name, description, developer, defaultApp, size, price, images, ui, icon. fixBlur is accepted and has no effect. |
| Event | lb-phone:phoneToggled is fired on the client with open (boolean) every time the phone opens or closes, next to fx-phone:phoneToggled. No shim is needed for it. |
| Page signal | The phone posts the plain string 'componentsLoaded' to a custom app page right after its own ready message, in lb-phone's order. |
| Page functions | html/compat/lb-components.js rebuilds lb-phone's page globals on FX Phone's iframe protocol. The shim serves it at the URL lb-phone apps already load. |
| Button colour | In pop-ups and context menus, lb-phone's color = 'red' is read like style = 'destructive'. |
| Notification shape | SendNotification reads title, content (also text or description), icon, thumbnail, app and timeout. |
#The shim resource
The shim is in fx-phone/setup/compat/lb-phone. It registers the export names listed on this page on client and server and passes each call on.
Start the shim only when the real lb-phone is not installed. The shim and lb-phone share a resource name and cannot both run.
#Install
- Copy the folder
setup/compat/lb-phoneto your resources, outsidefx-phone, and keep the folder namelb-phone. FiveM resolvesexports['lb-phone']by folder name. - Check that
lb-phone/ui/components.jsexists. It is a copy offx-phone/html/compat/lb-components.js. After an FX Phone update, copy the new file over it. - Start it after FX Phone:
cfgensure fx-phone
ensure lb-phone
Scripts that list 'lb-phone' under dependencies start unchanged, because a resource with that name is running.
#How calls are attributed
The shim passes along the name of the resource that called it. Custom apps, island trays, pop-ups, key binds and checks registered through the shim belong to the calling resource and are removed when that resource stops, the same as if it had called exports['fx-phone'] itself.
FX Phone accepts forwarded calls only from a resource named lb-phone or cylex_phone whose manifest carries fx_phone_shim 'yes'.
Argument shapes are FX Phone's. They follow lb-phone; where an export takes something different, the reference page for that export says so.
#Client exports answered by the shim
Each name below is forwarded to the FX Phone export of the same name.
| lb-phone export | FX Phone export | Reference |
|---|---|---|
IsOpen |
IsOpen |
Phone |
IsPhoneOnScreen |
IsOpen (alias IsPhoneOnScreen) |
Phone |
ToggleOpen |
ToggleOpen |
Phone |
OpenApp |
OpenApp |
Phone |
CloseApp |
CloseApp |
Phone |
GetPhoneNumber |
GetPhoneNumber |
Phone |
GetEquippedPhoneNumber |
GetPhoneNumber (alias GetEquippedPhoneNumber) |
Phone |
GetConfig |
GetConfig |
Phone |
GetSettings |
GetSettings |
Phone |
GetTheme |
GetTheme |
Phone |
HasPhoneItem |
HasPhoneItem |
Phone |
ToggleDisabled |
ToggleDisabled |
Phone |
IsDisabled |
IsDisabled |
Phone |
SetPhoneVariation |
SetPhoneVariation |
Phone |
SendNotification |
SendNotification |
Notifications |
PhoneNotification |
PhoneNotification |
Notifications |
AddCustomApp |
AddCustomApp |
Custom apps |
RemoveCustomApp |
RemoveCustomApp |
Custom apps |
SendCustomAppMessage |
SendCustomAppMessage |
Custom apps |
SendCustomNUIMessage |
SendCustomAppMessage (alias SendCustomNUIMessage) |
Custom apps |
SetInputFocus |
SetInputFocus |
Custom apps |
ToggleFocusKeepInput |
ToggleFocusKeepInput |
Custom apps |
SetAppBadge |
SetAppBadge |
Custom apps |
SetAppInstalled |
SetAppInstalled |
Custom apps |
SetAppHidden |
SetAppHidden |
Custom apps |
DoPhoneConfirmation |
DoPhoneConfirmation |
Dialogs |
ShowComponent |
ShowComponent |
Dialogs |
SetPopUp |
SetPopUp |
Dialogs |
SetContextMenu |
SetContextMenu |
Dialogs |
ShowMusicTray |
ShowMusicTray |
Dynamic Island |
UpdateMusicTray |
UpdateMusicTray |
Dynamic Island |
RemoveMusicTray |
RemoveMusicTray |
Dynamic Island |
ShowLiveTray |
ShowLiveTray |
Dynamic Island |
UpdateLiveTray |
UpdateLiveTray |
Dynamic Island |
RemoveLiveTray |
RemoveLiveTray |
Dynamic Island |
SetIslandIndicator |
SetIslandIndicator |
Dynamic Island |
CreateCall |
CreateCall |
Calls |
EndCall |
EndCall |
Calls |
IsInCall |
IsInCall |
Calls |
AddContact |
AddContact |
Calls |
OpenCamera |
OpenCamera |
Camera |
IsCameraOpen |
IsCameraOpen |
Camera |
SaveToGallery |
SaveToGallery |
Camera |
ToggleFlashlight |
ToggleFlashlight |
Battery and signal |
GetFlashlight |
GetFlashlight |
Battery and signal |
GetCryptoWallet |
GetCryptoWallet |
Other |
GetCoinValue |
GetCoinValue |
Other |
AddKeyBind |
AddKeyBind |
Other |
AddCheck |
AddCheck |
Checks |
RemoveCheck |
RemoveCheck |
Checks |
#Server exports answered by the shim
| lb-phone export | FX Phone export | Reference |
|---|---|---|
GetPhoneNumber |
GetPhoneNumber |
Users |
GetEquippedPhoneNumber |
GetPhoneNumber (alias GetEquippedPhoneNumber) |
Users |
GetSourceFromNumber |
GetSourceFromNumber |
Users |
GetNumberFromIdentifier |
GetNumberFromIdentifier |
Users |
GetIdentifierFromNumber |
GetIdentifierFromNumber |
Users |
GetUserData |
GetUserData |
Users |
GetUserDataBySource |
GetUserDataBySource |
Users |
GetUserDataList |
GetUserDataList |
Users |
SetUserData |
SetUserData |
Users |
WipeUser |
WipeUser |
Users |
FactoryReset |
FactoryReset |
Users |
SendNotification |
SendNotification |
Notifications |
PhoneNotification |
PhoneNotification |
Notifications |
NotifyEveryone |
NotifyEveryone |
Notifications |
QueueNotificationForOffline |
QueueNotificationForOffline |
Notifications |
EmergencyNotification |
EmergencyNotification |
Notifications |
DoPhoneConfirmation |
DoPhoneConfirmation |
Notifications |
SendMessage |
SendMessage |
Messages and mail |
SendCoords |
SendCoords |
Messages and mail |
SentMoney |
SentMoney |
Messages and mail |
SendMail |
SendMail |
Messages and mail |
SendCompanyMessage |
SendCompanyMessage |
Messages and mail |
GetOnDutyWorkers |
GetOnDutyWorkers |
Messages and mail |
CreateCall |
CreateCall |
Calls |
EndCall |
EndCall |
Calls |
IsInCall |
IsInCall |
Calls |
GetCall |
GetCall |
Calls |
AddContact |
AddContact |
Calls |
AddTransaction |
AddTransaction |
Bank |
GetBankData |
GetBankData |
Bank |
SetBankData |
SetBankData |
Bank |
AddInvoice |
AddInvoice |
Invoices |
GetInvoices |
GetInvoices |
Invoices |
DeleteInvoice |
DeleteInvoice |
Invoices |
AddCrypto |
AddCrypto |
Crypto |
RemoveCrypto |
RemoveCrypto |
Crypto |
AddCustomCoin |
AddCustomCoin |
Crypto |
GetCoin |
GetCoin |
Crypto |
GetOwnedCoin |
GetOwnedCoin |
Crypto |
AddGalleryPhoto |
AddGalleryPhoto |
Media |
GetPhotos |
GetPhotos |
Media |
AirShare |
AirShare |
Media |
GetSocialAccount |
GetSocialAccount |
Social |
GetActiveSocialAccount |
GetActiveSocialAccount |
Social |
SetSocialVerified |
SetSocialVerified |
Social |
SetAppData |
SetAppData |
App data |
GetAppDataFor |
GetAppDataFor |
App data |
GetConfig |
GetConfig |
Other |
GetVersionStatus |
GetVersionStatus |
Other |
AddCheck |
AddCheck |
Checks |
RemoveCheck |
RemoveCheck |
Checks |
On the server, GetPhoneNumber and GetEquippedPhoneNumber take a server id or a character identifier. A value that is numeric is tried as a server id first, then as an identifier.
A name that is not in these tables is not answered by the shim. FX Phone exports that are not listed here, such as the battery, SIM and landscape exports, are called on exports['fx-phone'] directly. The full list is in the export index.
#Custom app pages
lb-phone apps include this script in their HTML and call the globals it defines:
html<script src="https://cfx-nui-lb-phone/ui/components.js"></script>
With the shim running, that URL serves FX Phone's version of the script. The page runs unchanged and its calls go through FX Phone's iframe messages. The script does nothing when the page is not inside FX Phone.
| Page global | What it does on FX Phone |
|---|---|
resourceName, appName |
The resource that owns the page and the app id |
fetchNui(event, data) |
POST to https://<resource>/<event>, the app's own NUI callback. Returns the parsed answer, or null on failure |
getSettings() |
Resolves to { display: { theme } }, where theme is 'light' or 'dark' |
onSettingsChange(listener) |
Calls the listener with the same object when the theme changes |
sendNotification({ title, description, icon }) |
A banner from the app. content is read as description, thumbnail as icon |
setContextMenu({ title, buttons }) |
An action sheet. The chosen button's cb is called |
setPopUp({ title, description, buttons }) |
An alert. The chosen button's cb is called |
selectGallery({ includeVideos, includeImages, multiple, cb }) |
The gallery picker. cb receives { src, type, thumbnail }, or a list of them with multiple |
useCamera(cb, options) |
Opens the Camera app and calls cb with the URL of the saved item |
selectGif(cb), selectGIF(cb) |
The GIF picker. cb receives the URL |
selectEmoji(cb) |
The emoji picker. cb receives the emoji |
The script also tells the phone when a text field in the page has focus, so typing does not move the character. lb-phone pages do not need to do this themselves.
getSettings() returns only the theme. A page that reads other lb-phone settings from that object gets undefined for them.
An app that uses lb-phone's fallback path for NUI callbacks receives them as the client event <resource>:phoneApp:event with appId, action and data. See the custom app API.