I'm trying to set up a way to receive a url from another app. Like, you are in browser, click share, and send the link to another app (my app). I found this cordova plugin, and have integrated it in my app, but I continue to not show any url when I test it.
I get an alert that says:
getUri url:null
Any help would be great. Happy to add more code if helpful.
app.js
:
'use strict';
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', [
'ionic',
'firebase',
'starter.services',
'starter.directives',
'starter.controllers',
'ngSanitize'
])
.run(function($rootScope, $state, $ionicPlatform, Post) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory
// bar above the keyboard for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
This is the webintent:
if (window.plugins && window.plugins.webintent) {
window.plugins.webintent.getUri(function(url) {
alert("getUri url:"+url);
});
}
$rootScope.$on('$stateChangeError', function(event, toState, toParams,
fromState, fromParams, error) {
$state.go(error);
});
});
})
angular.module('starter.services', []);
angular.module('starter.directives', []);
angular.module('starter.controllers', []);
AndroidManifest.xml
:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" android:windowSoftInputMode="adjustPan" package="com.ionicframework.wefeed949805" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:launchMode="singleTop" android:name="wefeed" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
</manifest>
I've been working on something similar. I was able to get the url by using this plugin by Initsogar
The plugin can be found here https://github.com/Initsogar/cordova-webintent
You can get the incoming url as follows:
var incomingURL
window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT,
function(url) {
incomingURL = url
console.log(incomingURL);
}, function() {
incomingURL = false;
}
);
Hope this helps, and good luck on the app! Ionic is awesome :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With