UNPKG

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