Cordova WebIntent (receive Url)


#1

Hey, I’m working on having my app show up in the user’s android share section and the user can send urls to the app. I found this cordova plugin but I’m not having luck getting it to work. Any help here?

angular.module('starter', [
  'ionic']
.run(function($ionicPlatform, Post) {
    window.plugins.webintent.getUri(function(url) {
      if(url !== "") {
        var promise = Post.ExtractUrl(url);
        promise.then(function(postDetails) {
          Post.addPost(postDetails);
        })
      }
    })
}

#2

Any help here? I’m not receiving any errors in the console, just no url. Has anyone else tried sending data to an ionic app from a different app?


#3

Posted to SO with more code.


#4

smcavinney have you find where the problem was? I am facing the same problem.


#5

I opened an issue on the plugin’s GH page, and someone there mentioned that my implementation was incomplete.

I haven’t had time to work on the implementation, but I’ll be sure to update this post when/if I get it to work.


#6

Someone helped me out. It looks like the “GetURI” does not work as advertised. But using the GetExtra works fine.

var incomingURL
window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT,
      function(url) {
        incomingURL = url
        alert(incomingURL);
      }, function() {
        incomingURL = false
        alert("no url");
      }
  );

#7

Im trying to do something similar but I want to grab the data when onNewIntent is called (my launchmode is set so that onNewIntent is called if the app is already running).

In deviceReady I am doing this:

window.plugins.webintent.onNewIntent(Share.process);

Share is a service I have written:

.factory('Share', ['$log', '$cordovaToast',
    function($log,   $cordovaToast) {
        return {
            process: function(args) {
                $log.debug('onNewIntent', args);
                window.plugins.webintent.hasExtra(window.plugins.webintent.EXTRA_TEXT,
                    function() {
                       window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT,
                           function(url) {
                               $cordovaToast.showLongCenter('URL shared ' + url);
                           },
                           $log.error
                       );
                    },
                    $log.error
                );
                window.plugins.webintent.hasExtra(window.plugins.webintent.EXTRA_STREAM,
                    function() {
                        window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_STREAM,
                            function(stream) {
                                $cordovaToast.showLongCenter('STREAM shared ' + stream);
                            },
                            $log.error
                         );
                     },
                    $log.error
                );
            }
    };
}]);

I just get an error when trying to share an item to the app.


#8

I’m in the same boat. I check if the intent for EXTRA_STREAM exists, and it says it does. But when I try to get it, I get null. Anyone have any info on this?


#9

Wondering if you could elaborate on your code a little more. I am having trouble getting my app to show up in the list of “share to” when I am in another app. Thank you!