MOBILE-3320 http: Fix user agent initialization

main
Noel De Martin 2021-06-16 11:54:26 +02:00
parent 233d4c2842
commit 29ed804567
2 changed files with 27 additions and 14 deletions

View File

@ -0,0 +1,26 @@
// (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 { CoreApp } from '@services/app';
import { NativeHttp, Platform } from '@singletons';
export default async function(): Promise<void> {
if (!CoreApp.isMobile()) {
return;
}
await Platform.ready();
NativeHttp.setHeader('*', 'User-Agent', navigator.userAgent);
}

View File

@ -30,7 +30,7 @@ import { CoreUtils, PromiseDefer } from '@services/utils/utils';
import { CoreConstants } from '@/core/constants';
import { CoreError } from '@classes/errors/error';
import { CoreInterceptor } from '@classes/interceptor';
import { makeSingleton, Translate, FileTransfer, Http, Platform, NativeHttp } from '@singletons';
import { makeSingleton, Translate, FileTransfer, Http, NativeHttp } from '@singletons';
import { CoreArray } from '@singletons/array';
import { CoreLogger } from '@singletons/logger';
import { CoreWSError } from '@classes/errors/wserror';
@ -53,19 +53,6 @@ export class CoreWSProvider {
constructor() {
this.logger = CoreLogger.getInstance('CoreWSProvider');
this.init();
}
/**
* Initialize some data.
*/
protected async init(): Promise<void> {
await Platform.ready();
if (CoreApp.isMobile()) {
NativeHttp.setHeader('*', 'User-Agent', navigator.userAgent);
}
}
/**