Applications
Interacting with installed applications
The Switch.Application
API is used to interact with installed applications (game titles) and/or homebrew apps (.nro
files).
Instances of Switch.Application
can read the app's title, author information, and other metadata. It is also possible to retrieve a JPEG format image of the title's box art (256x256 JPEG format).
Additionally, working with Save Data is preferred to be done by first retrieving the Switch.Application
instance which your app is interested in working with.
Instance of current app
Use the special getter Switch.Application.self
to retrieve an instance of Switch.Application
which represents
the currently running nx.js application.
Using Switch.Application.self
considers the various methods in which a Switch
homebrew app can be launched, and loads the correct application metadata accordingly.
Iterate installed applications
The Switch.Application
class can be used as an iterator for the purposes of iterating over the installed titles.
This can be useful for i.e. rendering a title launcher screen or gathering information about which titles are currently
installed.
By Title ID
If you know the specific title ID for an installed application, use the new Switch.Application(id)
constructor to create an
instance of the class:
If the specified title is not currently installed on the system, then the accessor methods will throw an error.
By NRO file path
Pass a string or URL
as a file path to a homebrew .nro
file to the new Switch.Application()
constructor to create
and instance of the class with the:
Launching an application
Use the launch()
method to start up the application. This works for both installed titles as well as homebrew applications.
When launching homebrew applications, additional arguments passed to the launch()
method will be passed along as argv
.
For example, to launch Retroarch using the snes9x core, and pass the file path of the ROM to start: