inAppBrowser external links problem


#1

Hi. In Creator by default inAppBrowser opens external links in the app and the app CRASHES. No more use as there is no close or navigation buttons…

I tried to create a new hrefInappbrowser directive and use .decorator which I found in forums it also works for directives in order to replace the original directive that is included by default in Creator’s app.js

Links continue to open with inAppBrowser. I am so tired I desperately search for a soltuion but no way.

Can you help me make a directive or soemthing at APP level (not on individual links) that will open external links in systems’ browser???

I need it for many purposes. I need YouTube videos that are not syndicated and need to open externally to be able to do so… I need it to show ads in iFrame and be able to get them open in browser when clicked… And more. So i need ALL external links to open in normal external browser.

PLEASE HELP :frowning: :frowning: !!!


#2

just walk through this inAppBrowser Doc. specifically the option part of it.


#3

Anyone somehow more helpful guys? Is the .decorator approach correct in order to solve it without needing to extract .zip? A way to overwrite the Creator default behaviour in other words without leaving creator???

Thanks in advance :wink:

////// THIS IS WHAT I HAVE TRIED in directives.js file ///////

.directive('hrefInappbrowser', function($sce) {
  return {
    identifierSet: 'true',
    restrict: 'A',
    replace: false,
    transclude: false,
    link: function(scope, element, attrs) {
      var href = attrs['hrefInappbrowser'];
        
        
      attrs.$observe('hrefInappbrowser', function(val){
        href = val;
      });
      
      element.bind('click', function (event) {
    
        var inAppOptions = {
            location: 'yes',
            clearcache: 'yes',
            toolbar: 'yes',
            closebuttoncaption: 'Done',
        };   

        $sce.trustAsResourceUrl(href);        
        window.open(href, '_system', inAppOptions);

        event.preventDefault();
        event.stopPropagation();

      });
    }
  };
})

.decorator(
    "hrefInappbrowserDirective",
    function hrefInappbrowserDirectiveDecorator( $delegate ) {
        console.log( ". . . . . . . . . . . . . ." );
        console.log( "There are '"+$delegate.length+"' matching directives." );
        console.log( ". . . . . . . . . . . . . ." );
        var newDirective;
        
        $delegate.forEach(function(currentValue, index, arr){
            if (currentValue.identifierSet=='true'){
                newDirective = $delegate[index];
            }
        })

        // Demonstrating that our custom "label" identifierSet is available on the
        // object in the $delegate collection.
        console.log( "Directive chosen: "+newDirective.identifierSet);

        return( [ newDirective ] );
    }
)

#4

Any luck guys? Creator is such an awesome tool, I hope somebody knows how to fix this small but SO important issue without leaving creator interface :frowning: :pray: