Community
cancel
Showing results for 
Search instead for 
Did you mean: 
nermeen_m_
Beginner
109 Views

Can't access internet from my app with some mobile versions

Jump to solution

Hi all,

I developed an Intel XDK app which need connection to the internet (WIFI or using mobile data) for transferring file, I added the device plugin and file transfer. But when I tested the app it works fine in some mobiles, but didn't work on Samsung node4 ,iPhone 6plus and iPhone 4s(get An error has occurred code 3). when I opened the properties of the app and find what the app can access, I find it can access the camera and the photo but didn't access the WIFI or mobile data.

Although it is working fine and can access internet on other mobiles. I don't know what is the problem.

Can anyone help me please.

Tags (2)
0 Kudos
1 Solution
SithLord
New Contributor I
109 Views

 Content-Security-Policy or any whitelist settings should be checked for all external urls your app uses.  Some phone versions enforces these settings and some don't.

xdk_ats.png

 

View solution in original post

5 Replies
Elroy_A_Intel
Employee
109 Views

I recommend contacting the developer of the plugins in question that you are having problems with via their github pages or web sites. They will be able to fully answer or resolve your issue with the functionality that you are trying to access via their plugins.

nermeen_m_
Beginner
109 Views

thanks, I send mail for the developer of the plugins. I hope they can help

nermeen_m_
Beginner
109 Views

I send them E-mail, but no reply

this is my code

 

var pictureSource; 
var destinationType; 
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    pictureSource = navigator.camera.PictureSourceType;
    destinationType = navigator.camera.DestinationType;
}

function onPhotoDataSuccess(imageURI) {
    console.log(imageURI);
    var cameraImage = document.getElementById('image');

    cameraImage.style.display = 'block';
    cameraImage.style.width = '95%';

    cameraImage.src = imageURI;
}

function onPhotoURISuccess(imageURI) {
    console.log(imageURI);
    var galleryImage = document.getElementById('image');

    galleryImage.style.display = 'block';
    galleryImage.style.width = '95%';
     galleryImage.src = imageURI;
}

function capturePhoto() {
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
        quality: 30,
        targetWidth: 600,
        targetHeight: 600,
        destinationType: destinationType.FILE_URI,
        saveToPhotoAlbum: true
    });
      }


function getPhoto(source) {
    navigator.camera.getPicture(onPhotoURISuccess, onFail, {
        quality: 80,
        targetWidth: 600,
        targetHeight: 600,
        destinationType: destinationType.FILE_URI,
        sourceType: source
    });
}

function onFail(message) {
    //alert('Failed because: ' + message);
}

function upload() {
    var img = document.getElementById('image');
    var imageURI = img.src;
  
    var params = "server URL/webservice.asmx/SaveImage";
    var options = new FileUploadOptions();
    options.fileKey = "file";
    options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
    options.mimeType = "image/jpeg";
    options.chunkedMode = false;
    options.httpMethod = "POST";
    options.headers = {
          Connection: "close"
        };
    var ft = new FileTransfer();
    ft.upload(imageURI, params, win, fail,options);

}



function win(r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);
}

function fail(error) {
    alert("An error has occurred: Code = " + error.code);
    console.log("upload error source " + error.source);
    console.log("upload error target " + error.target);
}


this works fine in all android systems, but doesn't work in some IPhone devices like: Iphone6 plus, IPhone 4s(the app can't access WIFI or Mobile data)

can anyone tell me why?

SithLord
New Contributor I
110 Views

 Content-Security-Policy or any whitelist settings should be checked for all external urls your app uses.  Some phone versions enforces these settings and some don't.

xdk_ats.png

 

View solution in original post

nermeen_m_
Beginner
109 Views

Thanks a lot SithLord, this solved my problem. I tested it before publishing on Apple store, then I published on the store and it is working fine.

Really many thanks to you.

Reply