UNPKG

6.89 kBTypeScriptView Raw
1import { NgZone } from '@angular/core';
2import { BackButtonEventDetail, Platforms } from '@ionic/core';
3import { Subscription, Subject } from 'rxjs';
4import * as i0 from "@angular/core";
5export interface BackButtonEmitter extends Subject<BackButtonEventDetail> {
6 subscribeWithPriority(priority: number, callback: (processNextHandler: () => void) => Promise<any> | void): Subscription;
7}
8export declare class Platform {
9 private doc;
10 private _readyPromise;
11 private win;
12 /**
13 * @hidden
14 */
15 backButton: BackButtonEmitter;
16 /**
17 * The keyboardDidShow event emits when the
18 * on-screen keyboard is presented.
19 */
20 keyboardDidShow: any;
21 /**
22 * The keyboardDidHide event emits when the
23 * on-screen keyboard is hidden.
24 */
25 keyboardDidHide: Subject<void>;
26 /**
27 * The pause event emits when the native platform puts the application
28 * into the background, typically when the user switches to a different
29 * application. This event would emit when a Cordova app is put into
30 * the background, however, it would not fire on a standard web browser.
31 */
32 pause: Subject<void>;
33 /**
34 * The resume event emits when the native platform pulls the application
35 * out from the background. This event would emit when a Cordova app comes
36 * out from the background, however, it would not fire on a standard web browser.
37 */
38 resume: Subject<void>;
39 /**
40 * The resize event emits when the browser window has changed dimensions. This
41 * could be from a browser window being physically resized, or from a device
42 * changing orientation.
43 */
44 resize: Subject<void>;
45 constructor(doc: any, zone: NgZone);
46 /**
47 * @returns returns true/false based on platform.
48 * @description
49 * Depending on the platform the user is on, `is(platformName)` will
50 * return `true` or `false`. Note that the same app can return `true`
51 * for more than one platform name. For example, an app running from
52 * an iPad would return `true` for the platform names: `mobile`,
53 * `ios`, `ipad`, and `tablet`. Additionally, if the app was running
54 * from Cordova then `cordova` would be true, and if it was running
55 * from a web browser on the iPad then `mobileweb` would be `true`.
56 *
57 * ```
58 * import { Platform } from 'ionic-angular';
59 *
60 * @Component({...})
61 * export MyPage {
62 * constructor(public platform: Platform) {
63 * if (this.platform.is('ios')) {
64 * // This will only print when on iOS
65 * console.log('I am an iOS device!');
66 * }
67 * }
68 * }
69 * ```
70 *
71 * | Platform Name | Description |
72 * |-----------------|------------------------------------|
73 * | android | on a device running Android. |
74 * | capacitor | on a device running Capacitor. |
75 * | cordova | on a device running Cordova. |
76 * | ios | on a device running iOS. |
77 * | ipad | on an iPad device. |
78 * | iphone | on an iPhone device. |
79 * | phablet | on a phablet device. |
80 * | tablet | on a tablet device. |
81 * | electron | in Electron on a desktop device. |
82 * | pwa | as a PWA app. |
83 * | mobile | on a mobile device. |
84 * | mobileweb | on a mobile device in a browser. |
85 * | desktop | on a desktop device. |
86 * | hybrid | is a cordova or capacitor app. |
87 *
88 */
89 is(platformName: Platforms): boolean;
90 /**
91 * @returns the array of platforms
92 * @description
93 * Depending on what device you are on, `platforms` can return multiple values.
94 * Each possible value is a hierarchy of platforms. For example, on an iPhone,
95 * it would return `mobile`, `ios`, and `iphone`.
96 *
97 * ```
98 * import { Platform } from 'ionic-angular';
99 *
100 * @Component({...})
101 * export MyPage {
102 * constructor(public platform: Platform) {
103 * // This will print an array of the current platforms
104 * console.log(this.platform.platforms());
105 * }
106 * }
107 * ```
108 */
109 platforms(): string[];
110 /**
111 * Returns a promise when the platform is ready and native functionality
112 * can be called. If the app is running from within a web browser, then
113 * the promise will resolve when the DOM is ready. When the app is running
114 * from an application engine such as Cordova, then the promise will
115 * resolve when Cordova triggers the `deviceready` event.
116 *
117 * The resolved value is the `readySource`, which states which platform
118 * ready was used. For example, when Cordova is ready, the resolved ready
119 * source is `cordova`. The default ready source value will be `dom`. The
120 * `readySource` is useful if different logic should run depending on the
121 * platform the app is running from. For example, only Cordova can execute
122 * the status bar plugin, so the web should not run status bar plugin logic.
123 *
124 * ```
125 * import { Component } from '@angular/core';
126 * import { Platform } from 'ionic-angular';
127 *
128 * @Component({...})
129 * export MyApp {
130 * constructor(public platform: Platform) {
131 * this.platform.ready().then((readySource) => {
132 * console.log('Platform ready from', readySource);
133 * // Platform now ready, execute any required native code
134 * });
135 * }
136 * }
137 * ```
138 */
139 ready(): Promise<string>;
140 /**
141 * Returns if this app is using right-to-left language direction or not.
142 * We recommend the app's `index.html` file already has the correct `dir`
143 * attribute value set, such as `<html dir="ltr">` or `<html dir="rtl">`.
144 * [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
145 */
146 get isRTL(): boolean;
147 /**
148 * Get the query string parameter
149 */
150 getQueryParam(key: string): string | null;
151 /**
152 * Returns `true` if the app is in landscape mode.
153 */
154 isLandscape(): boolean;
155 /**
156 * Returns `true` if the app is in portrait mode.
157 */
158 isPortrait(): boolean;
159 testUserAgent(expression: string): boolean;
160 /**
161 * Get the current url.
162 */
163 url(): string;
164 /**
165 * Gets the width of the platform's viewport using `window.innerWidth`.
166 */
167 width(): number;
168 /**
169 * Gets the height of the platform's viewport using `window.innerHeight`.
170 */
171 height(): number;
172 static ɵfac: i0.ɵɵFactoryDeclaration<Platform, never>;
173 static ɵprov: i0.ɵɵInjectableDeclaration<Platform>;
174}
175
\No newline at end of file