UNPKG

6.67 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 * | cordova | on a device running Cordova. |
74 * | ios | on a device running iOS. |
75 * | ipad | on an iPad device. |
76 * | iphone | on an iPhone device. |
77 * | phablet | on a phablet device. |
78 * | tablet | on a tablet device. |
79 * | electron | in Electron on a desktop device. |
80 * | pwa | as a PWA app. |
81 * | mobile | on a mobile device. |
82 * | mobileweb | on a mobile device in a browser. |
83 * | desktop | on a desktop device. |
84 * | hybrid | is a cordova or capacitor app. |
85 *
86 */
87 is(platformName: Platforms): boolean;
88 /**
89 * @returns the array of platforms
90 * @description
91 * Depending on what device you are on, `platforms` can return multiple values.
92 * Each possible value is a hierarchy of platforms. For example, on an iPhone,
93 * it would return `mobile`, `ios`, and `iphone`.
94 *
95 * ```
96 * import { Platform } from 'ionic-angular';
97 *
98 * @Component({...})
99 * export MyPage {
100 * constructor(public platform: Platform) {
101 * // This will print an array of the current platforms
102 * console.log(this.platform.platforms());
103 * }
104 * }
105 * ```
106 */
107 platforms(): string[];
108 /**
109 * Returns a promise when the platform is ready and native functionality
110 * can be called. If the app is running from within a web browser, then
111 * the promise will resolve when the DOM is ready. When the app is running
112 * from an application engine such as Cordova, then the promise will
113 * resolve when Cordova triggers the `deviceready` event.
114 *
115 * The resolved value is the `readySource`, which states which platform
116 * ready was used. For example, when Cordova is ready, the resolved ready
117 * source is `cordova`. The default ready source value will be `dom`. The
118 * `readySource` is useful if different logic should run depending on the
119 * platform the app is running from. For example, only Cordova can execute
120 * the status bar plugin, so the web should not run status bar plugin logic.
121 *
122 * ```
123 * import { Component } from '@angular/core';
124 * import { Platform } from 'ionic-angular';
125 *
126 * @Component({...})
127 * export MyApp {
128 * constructor(public platform: Platform) {
129 * this.platform.ready().then((readySource) => {
130 * console.log('Platform ready from', readySource);
131 * // Platform now ready, execute any required native code
132 * });
133 * }
134 * }
135 * ```
136 */
137 ready(): Promise<string>;
138 /**
139 * Returns if this app is using right-to-left language direction or not.
140 * We recommend the app's `index.html` file already has the correct `dir`
141 * attribute value set, such as `<html dir="ltr">` or `<html dir="rtl">`.
142 * [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
143 */
144 readonly isRTL: boolean;
145 /**
146 * Get the query string parameter
147 */
148 getQueryParam(key: string): string | null;
149 /**
150 * Returns `true` if the app is in landscape mode.
151 */
152 isLandscape(): boolean;
153 /**
154 * Returns `true` if the app is in portrait mode.
155 */
156 isPortrait(): boolean;
157 testUserAgent(expression: string): boolean;
158 /**
159 * Get the current url.
160 */
161 url(): any;
162 /**
163 * Gets the width of the platform's viewport using `window.innerWidth`.
164 */
165 width(): any;
166 /**
167 * Gets the height of the platform's viewport using `window.innerHeight`.
168 */
169 height(): number;
170}
171
\No newline at end of file