Phonegap Serve, Build Phonegap and Mysql

Asked

Viewed 213 times

2

I’m developing an app using jquery mobile and phonegap. Question: why when I test the application on 'phonegap serve' of node.js works and when I download apk created by Buil Phonegap nay?

Example: if I try to communicate with a database (mysql) external through phonegap serves works normal, but by apk not.

My reference code is:

$(document).on('click', '#envcep', function() {
 var cep1 = $("#cep").val();
 var n = cep1.length;
 if (n < 8) {
  $("#mesg").text("CEP incompleto.");
  $("#dialog2").popup('open');
  return true;
 } else {

   var data = $("#app").serialize();
   $.ajax
      ({
       type: "POST",
       url: "http://meuwebsite.com.br/aplicativo/cep.php",
       data: data,
       cache: false,
       success:

    function(resposta) {...

Detail: my config.xml already has: access origin="*" access origin="http://meusite.com.br"

Where would the error be? What would be the difference between testing an application with phonegap serves and by the apk generated by build phonegap?

Thank you!!

  • android.permission.INTERNET ? http://stackoverflow.com/questions/23387007/phonegap-build-permissions-in-android

  • My permissions look like this: <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

  • The Cordova/Phonegap by default comes with a "lock" to Internet access by the application. But in its own documentation, it has a very well explained guide, where it teaches to remove this lock, so that it is possible to access the Web through the app. Follow the link: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/#supported-Cordova-Platforms

1 answer

3

Well, after a lot of trying, I figured out where the problem was:

In the new version of Phonegap, it creates in config.xml the following lines:

<access origin="*" />
<access origin="http://www.diskebeba.com.br/aplicativo" subdomains="true"/>
<access origin="tel:*" launch-external="yes" /> 
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>

I erased ALL and replaced only by:

access origin="*" Launch-External="yes"

Just remembering that it was tested only on Android.

I appreciate the answers and/or comments and hope this helps in some way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.