简体   繁体   中英

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. its working fine in browser and some of mobile phones. but its not working on newer version of androids such as 8+ version. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM