12 Replies Latest reply on Aug 19, 2017 6:39 PM by UbySoft

    Phonegap iOS externl links not opening

    saurabhc69710402 Level 1

      <script type="text/javascript" charset="utf-8">

       

          document.addEventListener("deviceready", onDeviceReady, false);

       

          // device APIs are available

          //

          function onDeviceReady() {

              // external url

              //var ref = window.open(encodeURI('https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item _name='+localStorage.getItemw.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item_name='+localStorage.getItem("title")+'&item_number='+localStorage.getItem("email")+' &amount='+localStorage.getItem("price")+'&first_name=&last_name=&address1=&address2=&city= &state=&zip=&night_phone_a=&night_phone_b=&night_phone_c=&email='+localStorage.getItem("em ail")+'&submit='), '_system', 'location=yes');

           

              // relative document

              ref = window.open('houses.html', '_self', 'location=no');

       

          }

       

       

      onDeviceReady();

       

       

          </script>

        • 1. Re: Phonegap iOS externl links not opening
          José Jesús Pérez Rivas Adobe Community Professional (Moderator)

          You can use the plugin "inappbrowser" both to open a web within your application or in an external web browser.

           

          In this url you have the necessary documentation: cordova-inappbrowser

           

          Regards!

          • 2. Re: Phonegap iOS externl links not opening
            UbySoft Level 1

            It may depend on the privacy changes for iOS 10 ... do you use the whitelist plugin? ... I have solved this: in the index.html I inserted gap in the default-src: * ... default-src gap: * ;

            <Meta http-equiv = "Content-Security-Policy" content = "img-src * data:; default-src gap: *; style-src 'self' 'unsafe-inline'; -inline '' unsafe-eval '*; media-src * ">

            • 3. Re: Phonegap iOS externl links not opening
              saurabhc69710402 Level 1

              not working ... giving blank screen

              • 4. Re: Phonegap iOS externl links not opening
                saurabhc69710402 Level 1

                tried but not working inApp browser

                • 5. Re: Phonegap iOS externl links not opening
                  UbySoft Level 1

                  Can you send your config file?

                  • 6. Re: Phonegap iOS externl links not opening
                    kerrishotts Adobe Employee

                    Also, share the code where you're trying to use the IAB.

                    • 7. Re: Phonegap iOS externl links not opening
                      saurabhc69710402 Level 1

                      <?xml version='1.0' encoding='utf-8'?>

                      <widget id="com.outrage.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">

                          <name>Outrage Messages</name>

                          <description>

                              Hello World sample application that responds to the deviceready event.

                          </description>

                          <author email="support@phonegap.com" href="http://phonegap.com">

                              PhoneGap Team

                          </author>

                          <content src="index.html" />

                          <preference name="DisallowOverscroll" value="true" />

                          <preference name="android-minSdkVersion" value="14" />

                          <icon src="icon.png" />

                          <platform name="android">

                              <icon density="ldpi" src="www/res/icon/android/drawable-ldpi-icon.png" />

                              <icon density="mdpi" src="www/res/icon/android/drawable-mdpi-icon.png" />

                              <icon density="hdpi" src="www/res/icon/android/drawable-hdpi-icon.png" />

                              <icon density="xhdpi" src="www/res/icon/android/drawable-xhdpi-icon.png" />

                              <icon density="xxhdpi" src="www/res/icon/android/drawable-xxhdpi-icon.png" />

                              <icon density="xxxhdpi" src="www/res/icon/android/drawable-xxxhdpi-icon.png" />

                              <splash density="land-ldpi" src="www/res/screen/android/drawable-land-ldpi-screen.png" />

                              <splash density="land-mdpi" src="www/res/screen/android/drawable-land-mdpi-screen.png" />

                              <splash density="land-hdpi" src="www/res/screen/android/drawable-land-hdpi-screen.png" />

                              <splash density="land-xhdpi" src="www/res/screen/android/drawable-land-xhdpi-screen.png" />

                              <splash density="land-xxhdpi" src="www/res/screen/android/drawable-land-xxhdpi-screen.png" />

                              <splash density="land-xxxhdpi" src="www/res/screen/android/drawable-land-xxxhdpi-screen.png" />

                              <splash density="port-ldpi" src="www/res/screen/android/drawable-port-ldpi-screen.png" />

                              <splash density="port-mdpi" src="www/res/screen/android/drawable-port-mdpi-screen.png" />

                              <splash density="port-hdpi" src="www/res/screen/android/drawable-port-hdpi-screen.png" />

                              <splash density="port-xhdpi" src="www/res/screen/android/drawable-port-xhdpi-screen.png" />

                              <splash density="port-xxhdpi" src="www/res/screen/android/drawable-port-xxhdpi-screen.png" />

                              <splash density="port-xxxhdpi" src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" />

                          </platform>

                          <platform name="ios">

                              <icon height="57" platform="ios" src="www/res/icon/ios/icon.png" width="57" />

                              <icon height="114" platform="ios" src="www/res/icon/ios/icon@2x.png" width="114" />

                              <icon height="40" platform="ios" src="www/res/icon/ios/icon-40.png" width="40" />

                              <icon height="80" platform="ios" src="www/res/icon/ios/icon-40@2x.png" width="80" />

                              <icon height="50" platform="ios" src="www/res/icon/ios/icon-50.png" width="50" />

                              <icon height="100" platform="ios" src="www/res/icon/ios/icon-50@2x.png" width="100" />

                              <icon height="60" platform="ios" src="www/res/icon/ios/icon-60.png" width="60" />

                              <icon height="120" platform="ios" src="www/res/icon/ios/icon-60@2x.png" width="120" />

                              <icon height="180" platform="ios" src="www/res/icon/ios/icon-60@3x.png" width="180" />

                              <icon height="72" platform="ios" src="www/res/icon/ios/icon-72.png" width="72" />

                              <icon height="144" platform="ios" src="www/res/icon/ios/icon-72@2x.png" width="144" />

                              <icon height="76" platform="ios" src="www/res/icon/ios/icon-76.png" width="76" />

                              <icon height="152" platform="ios" src="www/res/icon/ios/icon-76@2x.png" width="152" />

                              <icon height="29" platform="ios" src="www/res/icon/ios/icon-small.png" width="29" />

                              <icon height="58" platform="ios" src="www/res/icon/ios/icon-small@2x.png" width="58" />

                              <icon height="87" platform="ios" src="www/res/icon/ios/icon-small@3x.png" width="87" />

                              <splash height="1136" platform="ios" src="www/res/screen/ios/Default-568h@2x~iphone.png" width="640" />

                              <splash height="1334" platform="ios" src="www/res/screen/ios/Default-667h.png" width="750" />

                              <splash height="2208" platform="ios" src="www/res/screen/ios/Default-736h.png" width="1242" />

                              <splash height="1242" platform="ios" src="www/res/screen/ios/Default-Landscape-736h.png" width="2208" />

                              <splash height="1536" platform="ios" src="www/res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" />

                              <splash height="768" platform="ios" src="www/res/screen/ios/Default-Landscape~ipad.png" width="1024" />

                              <splash height="2048" platform="ios" src="www/res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" />

                              <splash height="1024" platform="ios" src="www/res/screen/ios/Default-Portrait~ipad.png" width="768" />

                              <splash height="960" platform="ios" src="www/res/screen/ios/Default@2x~iphone.png" width="640" />

                              <splash height="480" platform="ios" src="www/res/screen/ios/Default~iphone.png" width="320" />

                          </platform>

                          <platform name="wp8">

                              <icon height="99" platform="wp8" src="www/res/icon/wp8/ApplicationIcon.png" width="99" />

                              <icon height="159" platform="wp8" src="www/res/icon/wp8/Background.png" width="159" />

                              <splash height="1280" platform="wp8" src="www/res/screen/wp8/screen-portrait.jpg" width="768" />

                          </platform>

                          <platform name="windows">

                              <icon height="150" platform="windows" src="www/res/icon/windows/Square150x150Logo.scale-100.png" width="150" />

                              <icon height="30" platform="windows" src="www/res/icon/windows/Square30x30Logo.scale-100.png" width="30" />

                              <icon height="50" platform="windows" src="www/res/icon/windows/StoreLogo.scale-100.png" width="50" />

                              <splash height="300" platform="windows" src="www/res/screen/windows/SplashScreen.scale-100.png" width="620" />

                              <icon height="120" platform="windows" src="www/res/icon/windows/StoreLogo.scale-240.png" width="120" />

                              <icon height="44" platform="windows" src="www/res/icon/windows/Square44x44Logo.scale-100.png" width="44" />

                              <icon height="106" platform="windows" src="www/res/icon/windows/Square44x44Logo.scale-240.png" width="106" />

                              <icon height="70" platform="windows" src="www/res/icon/windows/Square70x70Logo.scale-100.png" width="70" />

                              <icon height="71" platform="windows" src="www/res/icon/windows/Square71x71Logo.scale-100.png" width="71" />

                              <icon height="170" platform="windows" src="www/res/icon/windows/Square71x71Logo.scale-240.png" width="170" />

                              <icon height="360" platform="windows" src="www/res/icon/windows/Square150x150Logo.scale-240.png" width="360" />

                              <icon height="310" platform="windows" src="www/res/icon/windows/Square310x310Logo.scale-100.png" width="310" />

                              <icon height="150" platform="windows" src="www/res/icon/windows/Wide310x150Logo.scale-100.png" width="310" />

                              <icon height="360" platform="windows" src="www/res/icon/windows/Wide310x150Logo.scale-240.png" width="744" />

                              <splash height="1920" platform="windows" src="www/res/screen/windows/SplashScreenPhone.scale-240.png" width="1152" />

                          </platform>

                          <access origin="*" />

                          <allow-intent href="http://*/*" />

                          <allow-intent href="https://*/*" />

                          <allow-intent href="tel:*" />

                          <allow-intent href="sms:*" />

                          <allow-intent href="mailto:*" />

                          <allow-intent href="geo:*" />

                      <!-- The above is equivalent to these three declarations -->

                      <allow-navigation href="http://*/*" />

                      <allow-navigation href="https://*/*" />

                      <allow-navigation href="data:*" />

                          <platform name="android">

                              <allow-intent href="market:*" />

                          </platform>

                          <platform name="ios">

                              <allow-intent href="itms:*" />

                              <allow-intent href="itms-apps:*" />

                              <config-file parent="PHOTOLIBRARY_USAGE_DESCRIPTION" target="*-Info.plist">

                                  <array>

                                      <dict>

                                          <key>Privacy - Photo Library Usage Description    </key>

                                          <string>$(PRODUCT_NAME) photo use</string>

                                      </dict>

                                  </array>

                              </config-file>

                              <config-file parent="NSPhotoLibraryAddUsageDescription" target="*-Info.plist">

                                  <array>

                                      <dict>

                                          <key>Privacy - Photo Library Usage Description    </key>

                                          <string>$(PRODUCT_NAME) photo use</string>

                                      </dict>

                                  </array>

                              </config-file>

                              <config-file parent="NSCameraUsageDescription" target="*-Info.plist">

                                  <array>

                                      <dict>

                                          <key>Privacy - Camera Usage Description </key>

                                          <string>$(PRODUCT_NAME) camera use</string>

                                      </dict>

                                  </array>

                              </config-file>

                          </platform>

                          <engine name="android" spec="^6.2.2" />

                          <plugin name="com.paypal.cordova.mobilesdk" spec="^3.5.0" />

                          <plugin name="cordova-plugin-battery-status" spec="~1.1.1" />

                          <plugin name="cordova-plugin-camera" spec="~2.1.1">

                              <variable name="CAMERA_USAGE_DESCRIPTION" value="app will acess sytem camera" />

                              <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App will access photo gallery" />

                          </plugin>

                          <plugin name="cordova-plugin-console" spec="~1.0.2" />

                          <plugin name="cordova-plugin-contacts" spec="~2.0.1" />

                          <plugin name="cordova-plugin-device" spec="~1.1.1" />

                          <plugin name="cordova-plugin-device-motion" spec="~1.2.0" />

                          <plugin name="cordova-plugin-device-orientation" spec="~1.0.2" />

                          <plugin name="cordova-plugin-dialogs" spec="~1.2.0" />

                          <plugin name="cordova-plugin-file" spec="~4.1.1" />

                          <plugin name="cordova-plugin-file-transfer" spec="~1.5.0" />

                          <plugin name="cordova-plugin-geolocation" spec="~2.1.0" />

                          <plugin name="cordova-plugin-globalization" spec="~1.0.3" />

                          <plugin name="cordova-plugin-inappbrowser" spec="~1.3.0" />

                          <plugin name="cordova-plugin-ios-camera-permissions" spec="^1.1.1">

                              <variable name="CAMERA_USAGE_DESCRIPTION" value="This app needs camera access" />

                              <variable name="MICROPHONE_USAGE_DESCRIPTION" value="This app needs microphone access" />

                              <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="This app needs photo library access" />

                          </plugin>

                          <plugin name="cordova-plugin-media" spec="~2.2.0" />

                          <plugin name="cordova-plugin-media-capture" spec="~1.2.0" />

                          <plugin name="cordova-plugin-network-information" spec="~1.2.0" />

                          <plugin name="cordova-plugin-splashscreen" spec="~3.2.1" />

                          <plugin name="cordova-plugin-statusbar" spec="~2.1.2" />

                          <plugin name="cordova-plugin-vibration" spec="~2.1.0" />

                          <plugin name="cordova-plugin-whitelist" spec="~1.2.1" />

                      </widget>

                      • 8. Re: Phonegap iOS externl links not opening
                        saurabhc69710402 Level 1

                        <!DOCTYPE html>

                        <html>

                          <head>

                            <title>Outrage</title>

                         

                            <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

                            <script src="http://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>  

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

                            <script src="js/application.js" type="text/javascript"></script>

                            <script src="js/general.js" type="text/javascript"></script>

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

                            <script type="text/javascript" charset="utf-8">

                         

                            document.addEventListener("deviceready", onDeviceReady, false);

                        var inAppBrowserRef;

                         

                         

                            // device APIs are available

                            //

                            function onDeviceReady() {

                                // external url

                                var ref = window.open(encodeURI('https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item _name='+localStorage.getItemw.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item_name='+localStorage.getItem("title")+'&item_number='+localStorage.getItem("email")+' &amount='+localStorage.getItem("price")+'&first_name=&last_name=&address1=&address2=&city= &state=&zip=&night_phone_a=&night_phone_b=&night_phone_c=&email='+localStorage.getItem("em ail")+'&submit='), '_system', 'location=yes');

                              

                                // relative document

                              

                        setTimeout(function(){

                        ref = window.open('houses.html', '_self', 'location=no');

                         

                         

                        }, 5000);

                         

                         

                         

                        onDeviceReady();

                         

                         

                            </script>

                          </head>

                          <body id="status-message">

                          </body>

                        </html>

                        • 9. Re: Phonegap iOS externl links not opening
                          kerrishotts Adobe Employee

                          Please see the documentation at: Inappbrowser - Apache Cordova

                           

                          First, I suggest using  `cordova.inAppBrowser.open()` instead of `window.open`. If you need to support the desktop, it's trivial to write a method that can handle both the cases where the plugin exists and where it doesn't.

                           

                          Second, you're calling your onDeviceReady() function directly. Don't -- you need to wait until Cordova fires the "deviceready" event on its own. As of right now, your method is executing before Cordova has had a chance to initialize everything.

                          • 10. Re: Phonegap iOS externl links not opening
                            saurabhc69710402 Level 1

                            <!DOCTYPE html>

                            <html>

                              <head>

                                <title>Outrage</title>

                             

                                <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

                                <script src="http://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>  

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

                                <script src="js/application.js" type="text/javascript"></script>

                                <script src="js/general.js" type="text/javascript"></script>

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

                                <script type="text/javascript" charset="utf-8">

                             

                                document.addEventListener("deviceready", onDeviceReady, false);

                            var inAppBrowserRef;

                             

                             

                                // device APIs are available

                                //

                                function onDeviceReady() {

                                    // external url

                                    //var ref = window.open(encodeURI('https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item _name='+localStorage.getItemw.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item_name='+localStorage.getItem("title")+'&item_number='+localStorage.getItem("email")+' &amount='+localStorage.getItem("price")+'&first_name=&last_name=&address1=&address2=&city= &state=&zip=&night_phone_a=&night_phone_b=&night_phone_c=&email='+localStorage.getItem("em ail")+'&submit='), '_system', 'location=yes');

                                  

                                    // relative document

                                  

                            //setTimeout(function(){

                            //ref = window.open('houses.html', '_self', 'location=no');

                             

                             

                            //}, 5000);

                             

                             

                            var raw_url="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item _name=w.paypal.com/cgi-bin/webscr?cmd=_xclick&business=leannaglennclark@yahoo.com&item_name=";

                             

                            var params_1=localStorage.getItem("title")+'&item_number='+localStorage.getItem("email")+'&am ount='+localStorage.getItem("price");

                             

                            var params_2='&first_name=&last_name=&address1=&address2=&city=&state=&zip=&night_phone_a=&ni ght_phone_b=&night_phone_c=&email='+localStorage.getItem("email")+'&submit=';

                             

                            var param=params_1+params_2;

                             

                            var url=encodeURI(raw_url+param);

                             

                            var target = "_blank";

                             

                             

                            var options = "location=yes,hidden=yes";

                             

                             

                            inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);

                             

                            inAppBrowserRef.addEventListener('loadstart', loadStartCallBack);

                             

                            inAppBrowserRef.addEventListener('exit', gotohome);

                             

                            window.location.href = "houses.html";

                             

                                }

                             

                            function gotohome(){

                             

                            window.location.href = "houses.html";

                            }

                             

                            function loadStartCallBack() {

                             

                             

                            $('#status-message').text("loading please wait ...");

                             

                             

                            }

                             

                             

                             

                             

                             

                                </script>

                              </head>

                              <body id="status-message">

                              </body>

                            </html>

                            • 11. Re: Phonegap iOS externl links not opening
                              saurabhc69710402 Level 1

                              Still no luck!!!! plz help

                              • 12. Re: Phonegap iOS externl links not opening
                                UbySoft Level 1

                                I did a little test, it works for me, I get the link for the zip file, I hope I can help you

                                https://github.com/UbySoft/Test-PhoneGap-InAppBrowser.git