$ons.platform

Utility methods to detect current platform.

Methods

Signature Description
select(platform) Sets the platform used to render the components. 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, or XR.
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.
isIOSSafari() Returns whether app is running in iOS Safari.
isWKWebView() Returns whether app is running in WKWebView.
isUIWebView() Returns whether app is running in UIWebView.
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 components. 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, or XR.

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.

isIOSSafari(): Boolean

Returns whether app is running in iOS Safari.

isWKWebView(): Boolean

Returns whether app is running in WKWebView.

isUIWebView(): Boolean

Returns whether app is running in UIWebView.

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.