mercredi 5 octobre 2016

Ionic/Cordova web intent only new

I am using cordova-webintent @http://ift.tt/QhgFyY

I want to only detect new intents. When a users wants to share a youtube video I grab the url from getExtra and fire to a new state. The problem is every time I close and reopen the app it detects the web intent and fires the view again.

//listen for text/string intents on device ready
    window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT,
        function(url) {
            // url is the value of EXTRA_TEXT
            console.log("web intent: " + url);

            //if youtube go to youtube video share
            if (url !== undefined || url !== '')
            {
              var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
              var match = url.match(regExp);

              if (match && match[2].length == 11) {
                console.log("youtube url detected");
                $rootScope.youtubeVideoShareUrl = url;
                $state.go('app.youtubeVideoShare');
              }
              else
              {
                console.log("not a youtube url");
              }
            }
        }, function() {
            // There was no extra supplied.
            console.log("no web intent detected");
        }



Aucun commentaire:

Enregistrer un commentaire