is: Platform Detection

The forge.is namespace allows you to detect the platform, orientation and connection status so you can branch your code accordingly.

While Forge allows you to build cross-platform apps from the same code, sometimes it may be necessary to do a specific action based on the platform that is running the code.

Note: It is not reliable to check connections status during your app's initialization: you should use forge.event.connectionStateChange.addListener() for that case. We guarantee to fire that event as the app starts up.

API

forge.is.mobile()

iOS, Android, Web

Returns true if running on a mobile device.

forge.is.web()

iOS, Android, Web

Returns true if running on as a hosted web app.

forge.is.development()

iOS, Android

Returns true if the app was installed onto the device from the command line or toolkit. Returns false if app was installed from the packaged version.

forge.is.android()

iOS, Android, Web

Returns true if running on an Android device.

forge.is.ios()

iOS, Android, Web

Returns true if running on an iOS device.

forge.is.orientation.portrait()

iOS, Android

Returns true if a mobile device has a portrait orientation.

forge.is.orientation.landscape()

iOS, Android

Returns true if a mobile device has a landscape orientation.

forge.is.connection.connected()

iOS, Android

Returns true if a mobile device has an active internet connection.

forge.is.connection.wifi()

iOS, Android

Returns true if a mobile device is connected via wifi.