10 Replies Latest reply on Apr 4, 2016 1:02 PM by Chris W. Griffith

    phonegap issues

    razb18907124
      ive installed the phonegap desktop app and phonegap mobile app. it works. but i have some issues:

       

       

      1. when changes done in the html code and saved, it doesnt appear on mobile automatically, i need to tap 3 finger and reconnect the whole server again..

       

       

      2. how to export this to app?

       

       

      i mean, getting apk file for android

       

       

      and getting ios file (which file is it btw?) for ios.

       

       

      3. is phonegap will be run fast with large projects too?

       

       


       

       

      thanks.

       

        • 1. Re: phonegap issues
          kerrishotts Adobe Community Professional

          1. Do you have a Content-Security-Policy META tag in your index.html? If you don't, you'll need one. If you do have one, please post what you have.

           

          For example (from the docs):

           

          <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *"> 


          For reload support, however, you need to apply a few changes (you need to allow unsafe inline scripts and web sockets). This should give you a good start:


              <meta http-equiv="Content-Security-Policy"
                    content="default-src 'self' data: ws: gap: https://ssl.gstatic.com;
                               media-src *;
                               style-src 'self' 'unsafe-inline';
                               script-src 'self' 'unsafe-inline' gap:"/>
          


          2. You can use either the Cordova or PhoneGap CLI or PhoneGap Build.

           

          3. It depends entirely upon how you've architected the app.

          • 2. Re: phonegap issues
            razb18907124 Level 1

            no i dont have what youve asked.

            also, the code didnt do anything.

            and only from the phonegap cli or phonegap build i can export the app?

            with th phonegap desktop i may not do that?

            also, which file is it for ios?
            apk file is for all who isnt ios, right?

            • 3. Re: phonegap issues
              razb18907124 Level 1

              btw thank for the help.

              • 4. Re: phonegap issues
                kerrishotts Adobe Community Professional

                no i dont have what youve asked.

                also, the code didnt do anything.

                 

                Please check your device logs (adb logcat for Android). It's still possible there's a CSP error preventing the auto reload from working. Also, try navigating to the address on your desktop browser and see if it auto reloads. It's also possible your app itself is preventing automatic reload, but I can't determine that without seeing some code. It might be useful to see your PG Desktop app's server log (click the icon that looks like a terminal prompt in the sidebar).

                 

                and only from the phonegap cli or phonegap build i can export the app?

                 

                Or the Cordova CLI.

                 

                with th phonegap desktop i may not do that?

                 

                No. The desktop app is intended for quick start / rapid iteration. See Step 5: Going Further | PhoneGap Docs

                 

                also, which file is it for ios?

                 

                iOS uses .IPA application bundles.

                 

                apk file is for all who isnt ios, right?

                 

                No; APK is an Android application bundle. Other platforms may have their own bundle formats.

                • 5. Re: phonegap issues
                  razb18907124 Level 1

                  oh so if i want to really use it i have to work with the cli and the desktop app is just "introduce" isnt it?
                  in the desktop app some plugins didnt work, such as geolocation and contact.

                  is this because they are not built in with the phonegap desktop?
                  (also, ive solved the refreshing problem).

                   

                  can you contact me via email or facebook?

                  if its okay for you.

                  thanks

                  • 6. Re: phonegap issues
                    kerrishotts Adobe Community Professional

                    oh so if i want to really use it i have to work with the cli and the desktop app is just "introduce" isnt it?

                    You will either have to use the CLI, or use PhoneGap Build. The latter is nice if you wish to avoid having to set up an entire development environment on your machine. The desktop app isn't just for an introduction, though, since you can use it for rapid iteration too and sketching out apps without having to delve into a terminal. It's really just providing options for the different ways devs work with the benefit of also being a quick way to get one's feet wet.

                     

                    in the desktop app some plugins didnt work, such as geolocation and contact.

                    is this because they are not built in with the phonegap desktop?

                    Define "didn't work". There are lots of reasons that plugins might not work, but you have to be a bit more specific (error messages help).

                     

                    That said, all core plugins are built into the PG developer app, so I would have expected them to work as long as they were being invoked correctly. Without seeing code, it's difficult to help.

                     

                    (also, ive solved the refreshing problem).

                    Could you post the fix for the benefit of the community?

                    • 7. Re: phonegap issues
                      razb18907124 Level 1

                      the refreshin problem fixed somehow i dont know.

                      but its slow - every change get modified after 5 seconds in the phone.

                       

                      also, geolocation plugin doesnt work, i paste the code from the old docs of phonegap:
                      <!DOCTYPE html>
                      <html>
                       
                      <head>
                         
                      <title>Device Properties Example</title>

                         
                      <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
                         
                      <script type="text/javascript" charset="utf-8">

                         
                      // Wait for device API libraries to load
                         
                      //
                          document
                      .addEventListener("deviceready", onDeviceReady, false);

                         
                      // device APIs are available
                         
                      //
                         
                      function onDeviceReady() {
                              navigator
                      .geolocation.getCurrentPosition(onSuccess, onError);
                         
                      }

                         
                      // onSuccess Geolocation
                         
                      //
                         
                      function onSuccess(position) {
                             
                      var element = document.getElementById('geolocation');
                              element
                      .innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                                                 
                      'Longitude: '          + position.coords.longitude             + '<br />' +
                                                 
                      'Altitude: '           + position.coords.altitude              + '<br />' +
                                                 
                      'Accuracy: '           + position.coords.accuracy              + '<br />' +
                                                 
                      'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                                                 
                      'Heading: '            + position.coords.heading               + '<br />' +
                                                 
                      'Speed: '              + position.coords.speed                 + '<br />' +
                                                 
                      'Timestamp: '          + position.timestamp                    + '<br />';
                         
                      }

                         
                      // onError Callback receives a PositionError object
                         
                      //
                         
                      function onError(error) {
                              alert
                      ('code: '    + error.code    + '\n' +
                                   
                      'message: ' + error.message + '\n');
                         
                      }

                         
                      </script>
                       
                      </head>
                       
                      <body>
                         
                      <p id="geolocation">Finding geolocation...</p>
                       
                      </body>
                      </html>

                       

                      and in the phone all i see is the Finding geolocation...

                      and nothing happenes.

                       

                      also, contact wasnt working with the desktop app, but now works with the cli..

                       

                      source of code implented here:PhoneGap API Documentation

                       

                      also, the new plugin api, from this link: Plugin APIs | PhoneGap Docs

                      is not that good or i just dont get it..

                      it doesnt come with full codes and it forget to mention critical things that without them the code just doesnt work..

                       

                      thanks.

                      • 8. Re: phonegap issues
                        kerrishotts Adobe Community Professional

                        Refreshing happens based on polling intervals, so waiting for 5s wouldn't be unheard of. That's still much faster than a typical build/deploy/launch cycle.

                         

                        You shouldn't have an issue using GPS or Contacts with the PG Developer app. That said, if you've ever denied permission to the PG Dev app to use these features, that might be why things aren't working. Check your privacy settings to make sure you haven't done so by accident.

                         

                        How long have you waited for a GPS response? It's possible the device is trying to figure out where you are, but hasn't done so in the time you are allotting.

                         

                        Also make sure there aren't any special characters that got copied into your code, like a smart quote or the like. I don't /see/ any, but I've only skimmed the code, and the colors make it difficult to read.

                        • 9. Re: phonegap issues
                          razb18907124 Level 1

                          the code im using for testing with phonegap is just a simple code from jquery mobile or framework7 basic code.

                          as i said, when im using the template that phonegap made it works and changes are made after 2 or 3 seconds.

                          when the code is blank and i just write "blabla" refreshing even becomes faster than 2 or 3 seconds.

                          when i put a whole website code (created by framework7 or jqmobile) it just doesnt work and need to press the 3 finger and open the whole server again.

                           

                          as gps issue: as i said the code is full copy paste from the phonegap reference.

                          ive just checked and i havnt declinied anything from the phonegap app, it has the rights to take the gps, contacts and everything.

                           

                          ive also tried using the android emulator by command the cli: phonegap emulate android.

                          but this is very very slow and realy unusable.

                           

                          so, what do you think is the right thing to do?
                          the phonegap serve is too slow.

                          the gps and contacts arent working.

                           

                          thanks!

                          • 10. Re: phonegap issues
                            Chris W. Griffith Adobe Community Professional

                            The Android Emulator is awful. I recommend look at genymotion.com as a replacement.

                             

                            Without seeing the code, I am guessing what might be occurring is that you have a lot a remotely hosted libraries, and your network connection maybe coming into play. If the libraries (JQM, Framework7) are referenced via http:// then point them to a locally stored version.

                             

                            Chris