0

I am new to Android. I am developing an app in Phonegap and implemented ajax calls to communicate with the server using the HTTPS protocol. It's working fine when I set debuggable to true in the manifest file. If I change it to false, it's not working. Please help me.

Thanks in advance.

dda
  • 6,030
  • 2
  • 25
  • 34
Bhaskar Reddy
  • 480
  • 5
  • 13

2 Answers2

3

The web service you're using needs to have a valid cert, one that is not self signed. Otherwise SSL will fail.

See here

Community
  • 1
  • 1
sciritai
  • 3,688
  • 1
  • 17
  • 22
0

Another issue which occurs in Android 4.0+ (but not in older versions like 2.3)... is you have to manually set the Authorization header in before send. Using the new username: password: options added in jQuery 1.7 do NOT work.

The example below illustrates what you have to do.
Note: This requires the base64 jquery plugin.

 $.ajax({
            url: "https://yoururl,
            type: method,
            dataType: 'json',
            // username: username,  // Doesn't work on ANDROID
            // password: password,  // Doesn't work on ANDROID
            beforeSend: function (xhr)
            {
                xhr.setRequestHeader("Authorization", "Basic " + $.base64.encode( username + ":" + password ));
            },
            data: options.data,
            success: function(response) {

            },
            error: function(jqXHR, textStatus, errorThrown) {

            }
        });
blak3r
  • 16,066
  • 16
  • 78
  • 98