MOBILE-3321 core: Decouple isMobile from App

main
Noel De Martin 2022-05-11 14:05:14 +02:00
parent 7fd6a4bd22
commit a0a138f686
24 changed files with 97 additions and 49 deletions

View File

@ -20,7 +20,6 @@ import {
AddonMessages,
} from '../../services/messages';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreConfig } from '@services/config';
import { CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
@ -28,6 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreConstants } from '@/core/constants';
import { IonRefresher } from '@ionic/angular';
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
import { CorePlatform } from '@services/platform';
/**
* Page that displays the messages settings page.
@ -66,7 +66,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy {
}
protected async asyncInit(): Promise<void> {
this.sendOnEnter = !!(await CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CoreApp.isMobile()));
this.sendOnEnter = !!(await CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CorePlatform.isMobile()));
}
/**

View File

@ -17,8 +17,8 @@ import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreFile } from '@services/file';
import { CorePlatform } from '@services/platform';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
@ -251,7 +251,7 @@ export class AddonModLtiProvider {
// Generate launcher and open it.
const launcherUrl = await this.generateLauncher(url, params);
if (CoreApp.isMobile()) {
if (CorePlatform.isMobile()) {
CoreUtils.openInApp(launcherUrl);
} else {
// In desktop open in browser, we found some cases where inapp caused JS issues.

View File

@ -16,9 +16,9 @@ import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreApp } from '@services/app';
import { CoreFile } from '@services/file';
import { CoreFilepool } from '@services/filepool';
import { CorePlatform } from '@services/platform';
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -394,7 +394,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
// Remove the unzipped folder.
promises.push(CoreFile.removeDir(path).catch((error) => {
if (error && (error.code == 1 || !CoreApp.isMobile())) {
if (error && (error.code == 1 || !CorePlatform.isMobile())) {
// Not found, ignore error.
} else {
throw error;

View File

@ -14,8 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreCronHandler } from '@services/cron';
import { CorePlatform } from '@services/platform';
import { CoreSites } from '@services/sites';
import { makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events';
@ -35,7 +35,7 @@ export class AddonNotificationsCronHandlerService implements CoreCronHandler {
* @return Time between consecutive executions (in ms).
*/
getInterval(): number {
return CoreApp.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
return CorePlatform.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
}
/**

View File

@ -13,7 +13,6 @@
// limitations under the License.
import { Component, Input, Output, EventEmitter, OnInit, ViewChild, ElementRef } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreConfig } from '@services/config';
import { CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
@ -21,6 +20,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { CoreConstants } from '@/core/constants';
import { CoreForms } from '@singletons/form';
import { CorePlatform } from '@services/platform';
/**
* Component to display a "send message form".
@ -55,7 +55,7 @@ export class CoreSendMessageFormComponent implements OnInit {
this.onSubmit = new EventEmitter();
this.onResize = new EventEmitter();
CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CoreApp.isMobile()).then((sendOnEnter) => {
CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CorePlatform.isMobile()).then((sendOnEnter) => {
this.sendOnEnter = !!sendOnEnter;
return;
@ -117,7 +117,7 @@ export class CoreSendMessageFormComponent implements OnInit {
// Enter clicked, send the message.
e.preventDefault();
e.stopPropagation();
} else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') {
} else if (!this.sendOnEnter && !CorePlatform.isMobile() && other == 'control') {
// Cmd+Enter or Ctrl+Enter, send message.
e.preventDefault();
e.stopPropagation();
@ -138,7 +138,7 @@ export class CoreSendMessageFormComponent implements OnInit {
if (this.sendOnEnter && !other) {
// Enter clicked, send the message.
this.submitForm(e);
} else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') {
} else if (!this.sendOnEnter && !CorePlatform.isMobile() && other == 'control') {
// Cmd+Enter or Ctrl+Enter, send message.
this.submitForm(e);
}

View File

@ -28,7 +28,6 @@ import { FormControl } from '@angular/forms';
import { IonTextarea, IonContent, IonSlides } from '@ionic/angular';
import { Subscription } from 'rxjs';
import { CoreApp } from '@services/app';
import { CoreSites } from '@services/sites';
import { CoreFilepool } from '@services/filepool';
import { CoreDomUtils } from '@services/utils/dom';
@ -42,6 +41,7 @@ import { CoreLoadingComponent } from '@components/loading/loading';
import { CoreScreen } from '@services/screen';
import { CoreCancellablePromise } from '@classes/cancellable-promise';
import { CoreDom } from '@singletons/dom';
import { CorePlatform } from '@services/platform';
/**
* Component to display a rich text editor if enabled.
@ -797,7 +797,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
const selection = window.getSelection()?.toString();
// When RTE is focused with a whole paragraph in desktop the stopBubble will not fire click.
if (CoreApp.isMobile() || !this.rteEnabled || document.activeElement != this.editorElement || selection == '') {
if (CorePlatform.isMobile() || !this.rteEnabled || document.activeElement != this.editorElement || selection == '') {
this.stopBubble(event);
}
}

View File

@ -17,7 +17,6 @@ import { MediaObject } from '@ionic-native/media/ngx';
import { FileEntry } from '@ionic-native/file/ngx';
import { MediaFile } from '@ionic-native/media-capture/ngx';
import { CoreApp } from '@services/app';
import { CoreFile, CoreFileProvider } from '@services/file';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
@ -27,6 +26,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreCaptureError } from '@classes/errors/captureerror';
import { CoreCanceledError } from '@classes/errors/cancelederror';
import { CoreText } from '@singletons/text';
import { CorePlatform } from '@services/platform';
/**
* Page to capture media in browser, or to capture audio in mobile devices.
@ -116,7 +116,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy {
this.title = 'core.captureimage';
}
this.isCordovaAudioCapture = CoreApp.isMobile() && this.isAudio;
this.isCordovaAudioCapture = CorePlatform.isMobile() && this.isAudio;
if (this.isCordovaAudioCapture) {
this.extension = Platform.is('ios') ? 'wav' : 'aac';

View File

@ -37,6 +37,7 @@ import { CoreWSUploadFileResult } from '@services/ws';
import { CoreSites } from '@services/sites';
import { CoreText } from '@singletons/text';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
/**
* Helper service to upload files.
@ -551,7 +552,7 @@ export class CoreFileUploaderHelperProvider {
media = medias[0]; // We used limit 1, we only want 1 media.
} catch (error) {
if (isAudio && this.isNoAppError(error) && CoreApp.isMobile()) {
if (isAudio && this.isNoAppError(error) && CorePlatform.isMobile()) {
// No app to record audio, fallback to capture it ourselves.
try {
media = await CoreFileUploader.captureAudioInApp();
@ -574,7 +575,7 @@ export class CoreFileUploaderHelperProvider {
}
// Make sure the path has the protocol. In iOS it doesn't.
if (CoreApp.isMobile() && path.indexOf('file://') == -1) {
if (CorePlatform.isMobile() && path.indexOf('file://') == -1) {
path = 'file://' + path;
}

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -35,7 +35,7 @@ export class CoreFileUploaderAlbumHandlerService implements CoreFileUploaderHand
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile();
return CorePlatform.isMobile();
}
/**

View File

@ -15,6 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -34,7 +35,7 @@ export class CoreFileUploaderAudioHandlerService implements CoreFileUploaderHand
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
}
/**

View File

@ -15,6 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -35,7 +36,7 @@ export class CoreFileUploaderCameraHandlerService implements CoreFileUploaderHan
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile() || CoreApp.canGetUserMedia();
return CorePlatform.isMobile() || CoreApp.canGetUserMedia();
}
/**

View File

@ -20,6 +20,7 @@ import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderH
import { CoreFileUploaderHelper } from '../fileuploader-helper';
import { CoreFileUploader } from '../fileuploader';
import { makeSingleton, Translate } from '@singletons';
import { CorePlatform } from '@services/platform';
/**
* Handler to upload any type of file.
@ -61,7 +62,7 @@ export class CoreFileUploaderFileHandlerService implements CoreFileUploaderHandl
icon: 'folder', // Cannot use font-awesome in action sheet.
};
if (CoreApp.isMobile()) {
if (CorePlatform.isMobile()) {
handler.action = async (
maxSize?: number,
upload?: boolean,

View File

@ -15,6 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -34,7 +35,7 @@ export class CoreFileUploaderVideoHandlerService implements CoreFileUploaderHand
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
}
/**

View File

@ -46,6 +46,7 @@ import { CoreDatabaseTable } from '@classes/database/database-table';
import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy';
import { CoreObject } from '@singletons/object';
import { lazyMap, LazyMap } from '@/core/utils/lazy-map';
import { CorePlatform } from '@services/platform';
/**
* Service to handle push notifications.
@ -204,7 +205,7 @@ export class CorePushNotificationsProvider {
* @return Whether the device can be registered in Moodle.
*/
canRegisterOnMoodle(): boolean {
return !!this.pushID && CoreApp.isMobile();
return !!this.pushID && CorePlatform.isMobile();
}
/**
@ -542,7 +543,7 @@ export class CorePushNotificationsProvider {
* @return Promise resolved when device is unregistered.
*/
async unregisterDeviceOnMoodle(site: CoreSite): Promise<void> {
if (!site || !CoreApp.isMobile()) {
if (!site || !CorePlatform.isMobile()) {
throw new CoreError('Cannot unregister device');
}
@ -624,7 +625,7 @@ export class CorePushNotificationsProvider {
const total = counters.reduce((previous, counter) => previous + counter, 0);
if (!CoreApp.isMobile()) {
if (!CorePlatform.isMobile()) {
// Browser doesn't have an app badge, stop.
return total;
}

View File

@ -26,6 +26,7 @@ import { CorePushNotifications } from '@features/pushnotifications/services/push
import { CoreConfig } from '@services/config';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreNavigator } from '@services/navigator';
import { CorePlatform } from '@services/platform';
/**
* Device Info to be shown and copied to clipboard.
@ -108,7 +109,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
' (' + window.screen.width + 'x' + window.screen.height + ')';
}
if (appProvider.isMobile()) {
if (CorePlatform.isMobile()) {
this.deviceInfo.deviceType = Platform.is('tablet') ? 'tablet' : 'phone';
if (appProvider.isAndroid()) {
this.deviceInfo.deviceOs = 'android';

View File

@ -30,6 +30,7 @@ import { CoreEvents } from '@singletons/events';
import { CoreLogger } from '@singletons/logger';
import { CoreSitePluginsModuleHandler } from '../classes/handlers/module-handler';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
const ROOT_CACHE_KEY = 'CoreSitePlugins:';
@ -90,7 +91,7 @@ export class CoreSitePluginsProvider {
applang: lang,
appcustomurlscheme: CoreConstants.CONFIG.customurlscheme,
appisdesktop: false,
appismobile: CoreApp.isMobile(),
appismobile: CorePlatform.isMobile(),
appiswide: CoreApp.isWide(),
appplatform: 'browser',
};

View File

@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { NativeHttp, Platform } from '@singletons';
export default async function(): Promise<void> {
if (!CoreApp.isMobile()) {
if (!CorePlatform.isMobile()) {
return;
}

View File

@ -29,6 +29,7 @@ import { asyncInstance } from '../utils/async-instance';
import { CoreDatabaseTable } from '@classes/database/database-table';
import { CorePromisedValue } from '@classes/promised-value';
import { Subscription } from 'rxjs';
import { CorePlatform } from '@services/platform';
/**
* Factory to provide some global functionalities, like access to the global app database.
@ -111,7 +112,7 @@ export class CoreAppProvider {
* Closes the keyboard.
*/
closeKeyboard(): void {
if (this.isMobile()) {
if (CorePlatform.isMobile()) {
Keyboard.hide();
}
}
@ -192,7 +193,7 @@ export class CoreAppProvider {
return 'market://details?id=' + storesConfig.android;
}
if (this.isMobile() && storesConfig.mobile) {
if (CorePlatform.isMobile() && storesConfig.mobile) {
return storesConfig.mobile;
}
@ -203,7 +204,7 @@ export class CoreAppProvider {
* Get platform major version number.
*/
getPlatformMajorVersion(): number {
if (!this.isMobile()) {
if (!CorePlatform.isMobile()) {
return 0;
}
@ -226,7 +227,7 @@ export class CoreAppProvider {
* @return Whether the app is running in an Android mobile or tablet device.
*/
isAndroid(): boolean {
return this.isMobile() && Platform.is('android');
return CorePlatform.isMobile() && Platform.is('android');
}
/**
@ -245,7 +246,7 @@ export class CoreAppProvider {
* @return Whether the app is running in an iOS mobile or tablet device.
*/
isIOS(): boolean {
return this.isMobile() && !Platform.is('android');
return CorePlatform.isMobile() && !Platform.is('android');
}
/**
@ -309,9 +310,10 @@ export class CoreAppProvider {
* Checks if the app is running in a mobile or tablet device (Cordova).
*
* @return Whether the app is running in a mobile or tablet device.
* @deprecated since 4.1. use CorePlatform instead.
*/
isMobile(): boolean {
return Platform.is('cordova');
return CorePlatform.isMobile();
}
/**
@ -630,7 +632,7 @@ export class CoreAppProvider {
* @param color RGB color to use as status bar background. If not set the css variable will be read.
*/
setStatusBarColor(color?: string): void {
if (!this.isMobile()) {
if (!CorePlatform.isMobile()) {
return;
}

View File

@ -27,6 +27,7 @@ import { CoreLogger } from '@singletons/logger';
import { makeSingleton, File, Zip, Platform, WebView } from '@singletons';
import { CoreFileEntry } from '@services/file-helper';
import { CoreText } from '@singletons/text';
import { CorePlatform } from '@services/platform';
/**
* Progress event used when writing a file data into a file.
@ -1261,7 +1262,7 @@ export class CoreFileProvider {
* @return Converted src.
*/
convertFileSrc(src: string): string {
return CoreApp.isMobile() ? WebView.convertFileSrc(src) : src;
return CorePlatform.isMobile() ? WebView.convertFileSrc(src) : src;
}
/**
@ -1271,7 +1272,7 @@ export class CoreFileProvider {
* @return Unconverted src.
*/
unconvertFileSrc(src: string): string {
if (!CoreApp.isMobile()) {
if (!CorePlatform.isMobile()) {
return src;
}

View File

@ -27,9 +27,9 @@ import { CoreUrlUtils } from '@services/utils/url';
import { CoreTextUtils } from '@services/utils/text';
import { makeSingleton, NavController, Router } from '@singletons';
import { CoreScreen } from './screen';
import { CoreApp } from './app';
import { CoreError } from '@classes/errors/error';
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
import { CorePlatform } from '@services/platform';
/**
* Redirect payload.
@ -318,7 +318,7 @@ export class CoreNavigatorService {
// Remove the parameter from our map if it's in there.
delete this.storedParams[value];
if (!CoreApp.isMobile() && !storedParam) {
if (!CorePlatform.isMobile() && !storedParam) {
// Try to retrieve the param from local storage in browser.
const storageParam = localStorage.getItem(value);
if (storageParam) {
@ -604,7 +604,7 @@ export class CoreNavigatorService {
this.storedParams[id] = value;
queryParams[name] = id;
if (!CoreApp.isMobile()) {
if (!CorePlatform.isMobile()) {
// In browser, save the param in local storage to be able to retrieve it if the app is refreshed.
localStorage.setItem(id, JSON.stringify(value));
}

View File

@ -0,0 +1,35 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Injectable } from '@angular/core';
import { makeSingleton, Platform } from '@singletons';
/**
* Extend Ionic's Platform service.
*/
@Injectable({ providedIn: 'root' })
export class CorePlatformService {
/**
* Checks if the app is running in a mobile or tablet device (Cordova).
*
* @return Whether the app is running in a mobile or tablet device.
*/
isMobile(): boolean {
return Platform.is('cordova');
}
}
export const CorePlatform = makeSingleton(CorePlatformService);

View File

@ -19,9 +19,9 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreConstants } from '@/core/constants';
import { makeSingleton } from '@singletons';
import { CoreUrl } from '@singletons/url';
import { CoreApp } from '@services/app';
import { CoreSites } from '@services/sites';
import { CoreText } from '@singletons/text';
import { CorePlatform } from '@services/platform';
/*
* "Utils" service with helper functions for URLs.
@ -461,7 +461,7 @@ export class CoreUrlUtilsProvider {
scheme == 'file' ||
scheme == 'filesystem' ||
scheme == CoreConstants.CONFIG.ioswebviewscheme ||
(CoreApp.isMobile() && scheme === 'http' && domain === 'localhost'); // @todo: Get served domain from ENV.
(CorePlatform.isMobile() && scheme === 'http' && domain === 'localhost'); // @todo: Get served domain from ENV.
}
/**

View File

@ -35,6 +35,7 @@ import { CoreConstants } from '@/core/constants';
import { CoreWindow } from '@singletons/window';
import { CoreColors } from '@singletons/colors';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
type TreeNode<T> = T & { children: TreeNode<T>[] };
@ -1015,7 +1016,7 @@ export class CoreUtilsProvider {
this.iabInstance = InAppBrowser.create(url, '_blank', options);
if (CoreApp.isMobile()) {
if (CorePlatform.isMobile()) {
let loadStopSubscription;
const loadStartUrls: string[] = [];
@ -1590,7 +1591,7 @@ export class CoreUtilsProvider {
* @return Whether the app can scan QR codes.
*/
canScanQR(): boolean {
return CoreApp.isMobile();
return CorePlatform.isMobile();
}
/**
@ -1615,7 +1616,7 @@ export class CoreUtilsProvider {
* @return Promise resolved with the QR string, rejected if error or cancelled.
*/
async startScanQR(): Promise<string | undefined> {
if (!CoreApp.isMobile()) {
if (!CorePlatform.isMobile()) {
return Promise.reject('QRScanner isn\'t available in browser.');
}

View File

@ -38,6 +38,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreSite } from '@classes/site';
import { CoreHttpError } from '@classes/errors/httperror';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
/**
* This service allows performing WS calls and download/upload files.
@ -994,7 +995,7 @@ export class CoreWSProvider {
options.responseType = options.responseType || 'json';
options.timeout = options.timeout === undefined ? this.getRequestTimeout() : options.timeout;
if (CoreApp.isMobile()) {
if (CorePlatform.isMobile()) {
// Use the cordova plugin.
if (url.indexOf('file://') === 0) {
// We cannot load local files using the http native plugin. Use file provider instead.