ons.platform

Utility methods to detect current platform.

Signature Description
select(platform) Sets the platform used to render the elements. Useful for testing.
isWebView() Returns whether app is running in Cordova.
isIPhone() Returns whether the device is iPhone.
isIPhoneX() Returns whether the device is iPhone X, XS, XS Max, XR, 11, 11 Pro, 11 Pro Max, 12 Mini, 12, 12 Pro or 12 Pro Max, 13 Mini, 13, 13 Pro, 13 Pro Max, 14, 14 Plus, 14 Pro, 14 Pro Max.
isIPad() Returns whether the device is iPad.
isIOS([forceActualPlatform]) Returns whether the OS is iOS. By default will return manually selected platform if it is set.
isIOS7above() Returns whether the iOS version is 7 or above.
isIPadOS() Returns whether the OS is iPadOS.
isIOSSafari() Returns whether app is running in iOS Safari.
isWKWebView() Returns whether app is running in WKWebView.
isAndroidPhone() Returns whether the device is Android phone.
isAndroidTablet() Returns whether the device is Android tablet.
isAndroid([forceActualPlatform]) Returns whether the OS is Android. By default will return manually selected platform if it is set.
isWP([forceActualPlatform]) Returns whether the OS is Windows phone. By default will return manually selected platform if it is set.
isBlackBerry([forceActualPlatform]) Returns whether the device is BlackBerry. By default will return manually selected platform if it is set.
isOpera([forceActualPlatform]) Returns whether the browser is Opera. By default will return manually selected platform if it is set.
isFirefox([forceActualPlatform]) Returns whether the browser is Firefox. By default will return manually selected platform if it is set.
isSafari([forceActualPlatform]) Returns whether the browser is Safari. By default will return manually selected platform if it is set.
isChrome([forceActualPlatform]) Returns whether the browser is Chrome. By default will return manually selected platform if it is set.
isIE([forceActualPlatform]) Returns whether the browser is Internet Explorer. By default will return manually selected platform if it is set.
isEdge([forceActualPlatform]) Returns whether the browser is Edge. By default will return manually selected platform if it is set.
select(platform)

Sets the platform used to render the elements. Useful for testing.

Parameters
Name Type Description
platform string Possible values are: “opera”, “firefox”, “safari”, “chrome”, “ie”, “android”, “blackberry”, “ios” or “wp”.
isWebView(): Boolean

Returns whether app is running in Cordova.

isIPhone(): Boolean

Returns whether the device is iPhone.

isIPhoneX(): Boolean

Returns whether the device is iPhone X, XS, XS Max, XR, 11, 11 Pro, 11 Pro Max, 12 Mini, 12, 12 Pro or 12 Pro Max, 13 Mini, 13, 13 Pro, 13 Pro Max, 14, 14 Plus, 14 Pro, 14 Pro Max.

isIPad(): Boolean

Returns whether the device is iPad.

isIOS([forceActualPlatform]): Boolean

Returns whether the OS is iOS. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isIOS7above(): Boolean

Returns whether the iOS version is 7 or above.

isIPadOS(): Boolean

Returns whether the OS is iPadOS.

isIOSSafari(): Boolean

Returns whether app is running in iOS Safari.

isWKWebView(): Boolean

Returns whether app is running in WKWebView.

isAndroidPhone(): Boolean

Returns whether the device is Android phone.

isAndroidTablet(): Boolean

Returns whether the device is Android tablet.

isAndroid([forceActualPlatform]): Boolean

Returns whether the OS is Android. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isWP([forceActualPlatform]): Boolean

Returns whether the OS is Windows phone. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isBlackBerry([forceActualPlatform]): Boolean

Returns whether the device is BlackBerry. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isOpera([forceActualPlatform]): Boolean

Returns whether the browser is Opera. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isFirefox([forceActualPlatform]): Boolean

Returns whether the browser is Firefox. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isSafari([forceActualPlatform]): Boolean

Returns whether the browser is Safari. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isChrome([forceActualPlatform]): Boolean

Returns whether the browser is Chrome. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isIE([forceActualPlatform]): Boolean

Returns whether the browser is Internet Explorer. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.
isEdge([forceActualPlatform]): Boolean

Returns whether the browser is Edge. By default will return manually selected platform if it is set.

Parameters
Name Type Description
forceActualPlatform Boolean If true, selected platform is ignored and the actual platform is returned.

Need Help?

If you have any questions, use our Community Forum or talk to us on Discord chat. The Onsen UI team and your peers in the community will work together to help solve your issues.

For bug reports and feature requests use our GitHub Issues page.