Making Sending a URL to my ionic app with web intent to work without crashing


#1

Good evening, I’ve been struggling with getting web intents to work without the app crashing, I thought it would be straight forward but its not seeming to work.

I first attempted to use the plugin:

ionic plugin add https://github.com/Initsogar/cordova-webintent

and then removed the plugin and i also tried a more recently updated fork:

ionic plugin add https://github.com/fluentstream/cordova-webintent

In my app.js file I putting the following code:

.run(function($ionicPlatform, $rootScope, $ionicHistory, $state) { 
  $ionicPlatform.ready(function() {
    window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT,
    function(url) {
      incomingURL = url;
      //alert(incomingURL);
      console.log(incomingURL);
    }, function() {
      incomingURL = false;
      //alert("no url");
      console.log("no url");
    });
  });
})

I also tried:

.run(function($ionicPlatform, $rootScope, $ionicHistory, $state) { 
  $ionicPlatform.ready(function() {
    window.plugins.webintent.getUri(function(url) {
      if(url !== "") {
          alert(url);//url is the url the intent was launched with
      }
    }); 
  });
})

In the file config.xml I would put:

<plugin name="WebIntent" value="com.borismus.webintent.WebIntent"/>

In the AndroidManifest.xml I would manually put in:

<activity android:name="ShareActivity">
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
</activity>

The app runs, but when I go to chrome and click the share button, and then choose my app, the app shuts down the following android message appears:

Unfortunately, MyAppName has stopped.

Can anybody suggest a plugin that can work with the ionic 1.1.0 and work…or am i forgetting something and doing something wrong.

Thank you!


#2

Fixed. It was an issue I was having with the android manifest. I was creating a separate activity for my intent…so don’t do that.

I wrote the full answer on stack overflow.

Would love to have some tutorials about modifying the android manifest and the ins and outs with ionic.

Thanks!