4 Replies Latest reply on Feb 21, 2017 1:49 PM by stichting opwekp67038633

    Weird behaviour InAppBrowser

    stichting opwekp67038633 Level 1

      My app was recently rejected by Apple.

      It allows the user to jump out of the app to do a donation.

      This is done with the InAppBrowser using target '_system' which works fine.

       

      However, after returning to the app, the same page is opened inside the app.

      Since asking for donations is against Apple's guidelines the app is rejected.

      Other external links do the same: They open the system browser, but upon return the same url is opened inside the app.

       

      The problem is I cannot find the reason for this behaviour. The Android version does not display this behavior.

      My code uses the following piece of code to open external links:

       

       

      function OpenExternalLink(link, target, location) {
          event.preventDefault();
          try {
              if (window.cordova && window.cordova.InAppBrowser) {
                  window.cordova.InAppBrowser.open(link, target, location);
              }
              else {
                  window.open(link, target, location);
              }
          } catch (err) {
              alert("OpenExternalLink: " + err.message);
          }
          return false;
      }

       

      Help?

       

        • 1. Re: Weird behaviour InAppBrowser
          kerrishotts Adobe Community Professional

          It would help to see the code you use that calls OpenExternalLink(), as well as your app's config.xml (minus identifying/secret information).

          • 2. Re: Weird behaviour InAppBrowser
            stichting opwekp67038633 Level 1

            I use Phonegap build and have no macbook available for debugging.

             

            The OpenExternalLink is dynamically injected by scanning the content which comes from a cms for a tags with an external link in the href attribute. I have pasted the piece of code that injects the calls below.

             

            My app is a multipage app consisting of a index.html and several helper pages. On IOS it uses the

             

            local-webserver plugin and loads the content from http://localhost:49000 in order to get consistent localStorage.

             

            Now the funny thing is that my index.html does not have the weird behaviour, but all other pages do. Even the exact same external link works fine in index.html but is reloaded upon return to the app on all other .html pages.

             

            And I cannot idenfity the factor that makes the difference. I've tried loading another page as start page by using the <content ..> tag, but that makes no difference. I've searched for different .js includes in the files and the order in which they are loaded but no dice.

             

            I've made the CSP exactly the same in all .html pages.

             

             

            This code has not been modified since last year with the exception of the usage of the local-webserver plugin. But removing that form the build makes no difference. I've also tried using an old version of the InAppBrowser plugin, but still no difference.

             

            Switching to '_blank' solves the problem, but my app will be rejected due to the donation request inside the app then. Sigh.

             

            function fixHyperlinks(where) {

                if (!where)

                    where = 'body';

                // loop door alle <a links> om er 'OpenExternalLink' van te maken

                $(where).find('a').each(function(idx, item) {

                    var link = $(item).attr('href');

                    if (link !== undefined && link !== "#" && link !== "") {

                        if (link.indexOf("://") > 0) {

                            link = link.toLowerCase();

                            if (link.indexOf("http") == 0 ||

                            link.indexOf("tel:") == 0 ||

                            link.indexOf("sms:") == 0 ||

                            link.indexOf("rtmp:") == 0 ||

                            link.indexOf("mailto:") == 0) {

                                $(item).attr('href', '');

                                $(item).attr("onclick", "OpenExternalLink('" + link + "', '_system', 'location=yes');return false;");

                            }

                        } else { // locallinks

                            $(item).attr('href', '#');

                            $(item).attr("onclick", "gotoPage('" + link + "');return false;");

                        }

                    }

                });

            }

            • 3. Re: Weird behaviour InAppBrowser
              stichting opwekp67038633 Level 1

              <?xml version='1.0' encoding='utf-8'?>
              <widget id="XXXXXXXXXXXXXXXX" version="5.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
                <name>Opwekking 2017</name>
                <description>
                  De Opwekking App voor 2017
                </description>
                <author email="xxxxxxxxxxx" href="xxxxxxxxxxxxxxxx">
                  Opwekking App Team
                </author>

                <plugin name="cordova-plugin-whitelist" />
                <allow-intent href="http://*/*"/>
                <allow-intent href="https://*/*"/>
                <allow-intent href="sms:*" />
                <allow-intent href="*" />

                <allow-navigation href="*" />
                <access origin="*" />

                <preference name="permissions" value="none" />
                <preference name="phonegap-version" value="cli-6.5.0" />
                <preference name="DisallowOverscroll" value="true" />
                <preference name="orientation" value="default" />
                <preference name="android-installLocation" value="preferExternal" />
                <preference name="AndroidLaunchMode" value="singleTask" />
                <preference name="SplashScreen" value="screen" />
                <preference name="SplashScreenDelay" value="4000" />
                <preference name="FadeSplashScreenDuration" value="1000" />
                <preference name="SplashShowOnlyFirstTime" value="false" />
                <preference name="AutoHideSplashScreen" value="true" />
                <preference name="StatusBarOverlaysWebView" value="false" />
                <preference name="android-minSdkVersion" value="16" />
                <preference name="android-build-tool" value="gradle" />

                <config-file parent="LSApplicationQueriesSchemes" platform="ios" target="*-Info.plist">
                  <array>
                    <string>whatsapp</string>
                  </array>
                </config-file>

                <icon src="www/icon.png" />

                <platform name="android">
                  <content src="start.html" />
                  <icon density="ldpi" src="www/res/icon/icon36.png" />
                  <icon density="mdpi" src="www/res/icon/icon48.png" />
                  <icon density="hdpi" src="www/res/icon/icon72.png" />
                  <icon density="xhdpi" src="www/res/icon/icon96.png" />
                  <splash density="hdpi" src="www/res/screen/android/splash-port-hdpi.png" />
                  <splash density="ldpi" src="www/res/screen/android/splash-port-ldpi.png" />
                  <splash density="mdpi" src="www/res/screen/android/splash-port-mdpi.png" />
                  <splash density="xhdpi" src="www/res/screen/android/splash-port-xhdpi.png" />
                </platform>

                <platform name="ios">
                  <content src="http://localhost:49000"/>
                  <icon height="29" src="res/icon/icon29.png" width="29" />
                  <icon height="58" src="res/icon/icon29@2x.png" width="58" />
                  <icon height="40" src="res/icon/icon40.png" width="40" />
                  <icon height="57" src="res/icon/icon57.png" width="57" />
                  <icon height="72" src="res/icon/icon72.png" width="72" />
                  <icon height="76" src="res/icon/icon76.png" width="76" />
                  <icon height="80" src="res/icon/icon40@2x.png" width="80" />
                  <icon height="120" src="res/icon/icon120.png" width="120" />
                  <icon height="152" src="res/icon/icon152.png" width="152" />
                  <!-- iPhone 5 / iPod Touch (5th Generation) -->
                  <splash src="res/screen/ios/splash2x.png" width="640" height="1136" />
                  <!-- iPhone 6 -->
                  <splash src="res/screen/ios/splash2x.png" platform="ios" width="750" height="1334" />
                  <splash src="res/screen/ios/splash2x.png" platform="ios" width="1242" height="2208" />
                  <splash src="res/screen/ios/splash1024l.png" platform="ios" width="2208" height="1242" />
                  <!-- iPad -->
                  <splash src="res/screen/ios/splash768p.png" width="768" height="1024" />
                  <splash src="res/screen/ios/splash1024l.png" width="1024" height="768" />
                  <!-- Retina iPad -->
                  <splash src="res/screen/ios/splash768p.png" width="1536" height="2048" />
                  <splash src="res/screen/ios/splash1024l.png" width="2048" height="1536" />
                </platform>

                <!--<gap:plugin name="cordova-plugin-wkwebview-engine" platform="ios" source="npm" />-->
                <gap:plugin name="local-webserver" platform="ios" source="npm" />
                <plugin name="cordova-plugin-inappbrowser" source="npm" />
                <plugin name="cordova-plugin-dialogs" source="npm" />
                <plugin name="cordova-plugin-vibration" source="npm" />
                <plugin name="cordova-plugin-console" source="npm" />
                <plugin name="cordova-plugin-device" source="npm" />
                <plugin name="cordova-plugin-geolocation" source="npm" />
                <plugin name="cordova-plugin-device-orientation" source="npm" />
                <plugin name="cordova-plugin-splashscreen" source="npm" />
                <plugin name="cordova-plugin-statusbar" source="npm" />
                <plugin name="cordova-plugin-network-information" source="npm" />

                <plugin name="phonegap-plugin-push" source="npm" spec="~1.8.4">
                  <param name="SENDER_ID" value="XXXXXXXXXXX" />
                </plugin>
                <plugin name="cordova-plugin-google-analytics" source="npm" />
                <plugin name="cordova-plugin-appavailability" source="npm" />
                <plugin name="cordova-plugin-x-socialsharing" source="npm" />
                <plugin name="cordova-plugin-customurlscheme" source="npm">
                  <param name="URL_SCHEME" value="opwekking" />
                </plugin>
                <plugin name="cordova-plugin-appversion" source="npm" />
              </widget>

              • 4. Re: Weird behaviour InAppBrowser
                stichting opwekp67038633 Level 1

                For now I have solved the issue by replacing the inappbrowser by the cordova-plugin-openurlext plugin.

                Works without any problem.