简体   繁体   English

离子 cordova - Cors 不适用于较新版本的 android,但它适用于 ZC31B32364CE19CA58FCD15068Z7

[英]Ionic cordova - Cors not working on newer version of android, But its working on android 7 or 6

I am having a problem with using typescript ionic, this is my code.我在使用 typescript 离子时遇到问题,这是我的代码。 its working fine in browser and some of mobile phones.它在浏览器和一些手机上运行良好。 but its not working on newer version of androids such as 8+ version.但它不适用于较新版本的机器人,例如 8+ 版本。 Please help me to fix this issue请帮我解决这个问题

import { Injectable } from '@angular/core';
import { HttpClient,HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { HTTP } from '@ionic-native/http/ngx';
import { Platform } from '@ionic/angular';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/timeout';
import {finalize} from 'rxjs/operators';
import { Observable } from 'rxjs/Observable'; 

@Injectable()
export class AccessProviders{
    server: string = 'http://example.com/api/';
    
    constructor(
        public http: HttpClient,
        public nativeHttp: HTTP
    ){}

    
    postData(body,file){
        let type = "application/json; charset=UTF-8";
        let headers = new HttpHeaders({ 'Content-Type': type });
        let options = {
            headers: headers
        }
        return this.http.post(this.server+file,JSON.stringify(body),options).map(res => res);
    }
}

Please see the below link this may help.请参阅下面的链接,这可能会有所帮助。 as mentioned google has updated their policies.如前所述,谷歌已经更新了他们的政策。

https://medium.com/@mountainappstudio/api-not-running-on-android-oreo-8-0-or-higher-version-problem-solved-ded5cc614d5e https://medium.com/@mountainappstudio/api-not-running-on-android-oreo-8-0-or-higher-version-problem-solved-ded5cc614d5e

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Periodicworkrequest 在较新版本的 android 中不起作用 - Periodicworkrequest not working in newer version of android 离子科尔多瓦建立Android无法正常工作 - Ionic Cordova build android not working 离子cordova运行android不适用于cordova 9.0.0 - ionic cordova run android not working with cordova 9.0.0 约束在较新版本的 android studio 中无法正常工作 - Constraints not working properly in a newer version of android studio “ionic cordova run android”不适用于cordova-android@7.0.0 - "ionic cordova run android" not working with cordova-android@7.0.0 Cordova 离子应用程序不适用于 Android 9 && 10 - Cordova ionic app not working on Android 9 && 10 离子和科尔多瓦-Css Active在Android设备上不起作用 - ionic and cordova - css active not working on android device 离子科尔多瓦运行/构建/模拟Android无法正常工作 - Ionic cordova run/build/emulate android not working 谷歌地图不适用于离子科尔多瓦运行android - Google maps not working with ionic cordova run android 离子框架+科尔多瓦。 WebSocket无法在android发布版本中使用,但调试版本可以正常运行 - ionic framework + cordova. WebSocket is not working in the android release version, but the debug version works correctly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM