欧洲杯官网投注

Ionic Docs Docs

Native

Search docs/
Search docs/
Ionic Docs Docs
  • Structure
  • Responsive Grid
  • Global StylesheetsCSS Utilities
  • Basics
  • Platform Styles
  • CSS VariablesColorsThemesDark ModeAdvancedColor Generator
  • Overview
  • Build Your First App
    LifecycleNavigation/RoutingConfigPlatform
  • Testing
  • StoragePerformanceProgressive Web Apps
  • Overview
  • Quickstart
  • Build Your First App
    LifecycleNavigation/RoutingConfigPlatform UtilsProgressive Web AppsTesting
  • Overview
  • Build Your First App
  • LifecycleNavigation/Routing
  • Animations
  • Gestures
  • iOS App Store
  • Android Play StoreProgressive Web App (PWA)Electron Desktop App
  • Security
  • Debugging
  • Build ErrorsRuntime ErrorsNative ErrorsCORS Errors
  • Fundamentals
  • Cross PlatformWeb ViewWhat are PWAs?
  • How to Contribute
  • Code of Conduct
  • Glossary
  • VersioningRelease NotesGitHub Changelog
  • Support Policy
  • Browser Support
  • Migration
  • Books
  • CoursesGuidesPostsToolsVideos

    Platform

    Contents

    The Platform service can be used to get information about your current device. You can get all of the platforms associated with the device using theplatforms欧洲杯官网投注 method, including whether the app is being viewed from a tablet, if it's on a mobile device or browser, and the exact platform (iOS, Android, etc). You can also get the orientation of the device, if it uses right-to-left language direction, and much much more. With this information you can completely customize your app to fit any device.

    Usage

    import { Platform } from '@ionic/angular';@Component({...})export class MyPage {  constructor(public platform: Platform) {  }}
    CopyCopied

    Methods

    is(platformName: Platforms) => boolean

    Depending on the platform the user is on,is(platformName) will return true or false. Note that the same app can return true for more than one platform name. For example, an app running from an iPad would return true for the platform names:mobile, ios,ipad, and tablet. Additionally, if the app was running from Cordova thencordova欧洲杯官网投注 would be true.

    Parameters

    NameType Description
    platformNamePlatformsName of the platform. Available options are android, capacitor, cordova, desktop, electron, hybrid, ios, ipad, iphone, mobile, phablet, pwa, tablet

    Platforms

    Below is a table listing all the possible Platforms values along with corresponding descriptions.

    Platform Name Description
    android a device running Android
    capacitora device running Capacitor
    cordovaa device running Cordova
    desktopa desktop device
    electrona desktop device running Electron
    hybrida device running Capacitor or Cordova
    iosa device running iOS
    ipadan iPad device
    iphonean iPhone device
    mobilea mobile device
    mobileweba web browser running in a mobile device
    phableta phablet device
    pwaa PWA app
    tableta tablet device

    platforms() => string[]

    Depending on what device you are on,platforms can return multiple values. Each possible value is a hierarchy of platforms. For example, on an iPhone, it would returnmobile, ios, andiphone.

    ready() => Promise<string>

    Returns a promise when the platform is ready and native functionality can be called. If the app is running from within a web browser, then the promise will resolve when the DOM is ready. When the app is running from an application engine such as Cordova, then the promise will resolve when Cordova triggers thedeviceready event. The resolved value is thereadySource, which states the platform that was used.

    For example, when Cordova is ready, the resolved ready source iscordova. The default ready source value will bedom. ThereadySource is useful if different logic should run depending on the platform the app is running from. For example, only Capacitor and Cordova can execute the status bar plugin, so the web should not run status bar plugin logic.

    isRTL() => boolean

    Returns if this app is using right-to-left language direction or not. We recommend the app'sindex.html file already has the correct dir attribute value set, such as <html dir="ltr"> or <html dir="rtl">.

    isLandscape() => boolean

    Returns true if the app is in landscape mode.

    isPortrait() => boolean

    Returns true if the app is in portrait mode.

    width() => number

    Gets the width of the platform's viewport using window.innerWidth.

    height() => number

    Gets the height of the platform's viewport using window.innerHeight.

    url() => string

    欧洲杯官网投注Get the current url.

    testUserAgent(expression: string) => boolean

    Returns true if the expression is included in the user agent string.

    Parameters

    NameType Description
    expression stringThe string to check in the user agent

    Events

    pause

    The pause event emits when the native platform puts the application into the background, typically when the user switches to a different application. This event emits when a Cordova/Capacitor app is put into the background but doesn't fire in a standard web browser.

    Usage

    this.platform.pause.subscribe(async () => {  alert('Pause event detected');});
    CopyCopied
    resize

    The resize欧洲杯官网投注 event emits when the browser window has changed dimensions. This could be from a browser window being physically resized, or from a device changing orientation.

    Usage

    this.platform.resize.subscribe(async () => {  alert('Resize event detected');});
    CopyCopied
    resume

    The resume event fires when the native platform pulls the application out from the background. This event emits when a Cordova/Capacitor app comes out from the background but doesn't fire in a standard web browser.

    Usage

    this.platform.resume.subscribe(async () => {  alert('Resume event detected');});
    CopyCopied
    Previous
    Config
    Next
    Testing