napolitano / cordova-plugin-intent Goto Github PK
View Code? Open in Web Editor NEWPlugin for apache cordova (Android Only) that allows interaction with the intent.
License: MIT License
Plugin for apache cordova (Android Only) that allows interaction with the intent.
License: MIT License
Hello,
First of all,thank you for this plugin, works flawlessly. I was just guessing how can I access a file that has been sent to my application. I tried to use the file cordova plugin, trying to open the path that I receive on the intent , but I'm unable to access the contents, probably because lack of permissions. Is there any other way of doing this ?
Thanks in advance
Hi,
My question is to see if anyone has managed to make this plugin for iOS?
I have followed the steps that are at the end of this plugin but I haven't managed to get the application to appear in the share list. It doesn't give me any error but it doesn't do anything either.
I could not understand whether it will work on ios or not. As you have mention for IOS and gave a basic implamentation example, there is not ant file in sources.
Could you clearify, we could use it in ios (on ionic plaftorm) and if yes how.
Thank you.
Hello,
Thank you for the work on this plugin.
When I share something from the browser my app starts up I get a error in the getCordovaIntent()
window.plugins.intent.getCordovaIntent(function (intent) {
alert(intent)
}, function () {
alert('error in getCordovaIntent')
});
Not sure why the event is firing? Is there something else I might need to set or add?
Any help would be great.
Additional info below
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
using version .1.3
Hi.
Thanks for the great plugin!.
I have noticed that in some cases the intent data (when sending URL from chrome) comes parcelled and then doesn't get unpacked (looking at the data it just shows: extras : Bundle[mParcelledData.dataSize=664] )
I made a small hack to fix it for me by just pulling out the data to a string but I'm not sending it as pull request as I think there must be a more elegant solution ;)
try {
intentJSON = new JSONObject();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if(items != null) {
intentJSON.put("clipItems", new JSONArray(items));
}
}
// change to ensure all data is pulled from extras
StringBuilder str = new StringBuilder();
Bundle bundle = intent.getExtras();
if (bundle != null) {
Set keys = bundle.keySet();
Iterator it = keys.iterator();
while (it.hasNext()) {
String key = it.next();
str.append(key);
str.append(":");
str.append(bundle.get(key));
str.append("\n\r");
}
}
intentJSON.put("bundle",str.toString());
// end of change
intentJSON.put("type", intent.getType());
Sorry my mistake..
The plugin works perfectly when launchmode is singleTop, but creates multiple instances of my application. When attempting to use singleTask, the intent was no longer working. Could you provide an example using singleTask launchmode to see it working?
Please update
https://www.npmjs.com/package/cordova-plugin-intent
to the latest release.
Hello!
Sharing a webpage from Chrome I'd like to get that page URI. I'm using setNewIntentHandler
and getting this object:
{
action: "android.intent.action.SEND",
clipItems: [
extension: "jpeg"
type: "image/jpeg"
uri: "content://com.android.chrome.FileProvider/images/screenshot/1455964158897645869502.jpg"
],
component: "ComponentInfo{com.ionicframework.starter/com.ionicframework.starter.MainActivity}"
extras: "Bundle[mParcelledData.dataSize=868]"
flags: 55050241
type: "text/plain"
}
As you see there's no shared page URI. So how to get it?
In my current config.xml
<config-file target="AndroidManifest.xml" parent="activity">
<intent-filter android:label="@string/launcher_name">
<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" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*"/>
</intent-filter>
</config-file>
Hello:
I can read the outer fields just find and the clipItems object without a issue. However the extras object I'm having a issue reading the "android.intent.extra.TEXT" and " android.intent.extra.SUBJECT" fields.
I have tried:
intent.android.intent.extra.TEXT
intent.extra.TEXT
I'm a little confuse here.
what's the proper way to ready the extra object.
Hi, I'm trying to use this plugin and I'm getting intet object but clipItems element is missing. How is it possible. What am I doing wrong? I have exactly the same configuration in my AndroidManifes.xml as on the plugin page.
And my action element is android.intent.action.MAIN instead of android.intent.action.SEND_MULTIPLE
Thanks
Hi,
Is there any way using this plugin, we can get the applied CSS of selected browser content and pass to application using Intent?
Thanks,
Niketa.
I tested with sharing an image from Whatsapp but I get an error "invalid action" on window.plugins.intent.getRealPathFromContentUrl().
I insert that code into plist, but still cannot open image or text with my app. I have known something about that preference, but don't know what is wrong.
hi, i have a problem when opening a project that this plugin installed.
anyone can help ?
screen shot with the error
Hello @napolitano!
First of all, thanks for this plugin - it works way better than the WebIntent plugin. It would be really nice if it could support API levels starting from 15-16 (Android 4.0-4.1) as they still account for 20% of the active devices.
Is there any technical reason for choosing API level 19?
I'll be willing to contribute if needed. Thanks!
When sharing to my application from a thirdparty app like google drive, I get files paths looking like this:
content://com.google.android.apps.docs.storage.legacy/something...
For some reason, using getRealPathFromContentUrl fires the success callback, but the variable passed to it is null. What can I do to open the file shared in this way? I tried using window.resolveLocalFileSystemURL on the content URL but that doesn't work (it returns a file error). I replaced "content://" with "file://" but this doesn't work either, the file cannot be opened as well. What could be the reason for that? Opening files from the device's photo gallery works fine! Tested on a Samsung Galaxy Alpha with Android 5.0.2. The app was created using PGB cli 6.3.0.
It would be reall nice if someone could point me in the right direction!
I notice when I use the share option within my app, my own application will appear in the list however if I try to share something to the same application it can't process it - nothing happens.
Anyone else faced this? Got any ideas how to fix/remedy? (eg. Prevent sending application to appear in the list when sharing)
hey, i know that this might not be necessarily your issue but I'm gonna say it here anyway since other people might search for it.
adding your plugin to visual studio via "cordova plugin add cordova-plugin-intent" will install an example app, that has a file in it, that has a very long path.
\plugins\com.napolitano.cordova.plugin.intent\example\app\platforms\android\CordovaLib\build\intermediates\classes\debug\org\apache\cordova\
The latest version of visual studio (here visual studio 2015 enterprise Update 3) will say something like ' %(Fullpath) cannot be applied to' the file above. Older versions will just crash.
deleting the file or renaming it will help.
I want launch new Android activity from my native library using Intent when user clicked on button.
How can I start new activity when click on button?
whats the proper way of calling this method? I'm trying to use it like but I'm getting the error saying the getRealpathFromContentUrl() is not a function?
window.plugins.intent.getCordovaIntent(function (intent) {
for (var i = 0, l = intent.clipItems.length; i < l; i++) {
var obj = intent.clipItems[i];
window.plugins.intent.getRealPathFromContentUrl(obj.uri, function (realPath) {
console.log(realPath);
},function () {
alert('error in getRealPathFromContentUrl')
});
}
}
Not sure why I am not able to make it work.
Here is what I have done.
Opened PhoneGap desktop app (Windows 10)
Created a new Hello World App.
Open command prompt, cd to the app directory
phonegap local plugin add https://github.com/napolitano/cordova-plugin-intent
It installed the plug in.
In plugins directory I can see this directory:
com.napolitano.cordova.plugin.intent
In config.xml I have:
<plugin name="com.napolitano.cordova.plugin.intent" spec="https://github.com/napolitano/cordova-plugin-intent" />
In AndroidManifest.xml I have:
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent-filter>
</activity>
</application>
So, any link with https schema is giving me option to open my app. This is fine.
In index.html I have:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener('deviceReady', function(){
window.plugins.intent.getCordovaIntent(function (Intent) {
console.log(Intent);
}, function () {
console.log('Error');
});
});
</script>
In Chrome Console, I am getting this error:
Uncaught TypeError: Cannot read property 'getCordovaIntent' of undefined
So, I think the plug in is not initiated at all. Or it is something else? Whatever it is, I am struggling for two days to make it work. Please let me know what wrong I am doing.
Hi!
With this plugin we need to manually create the hook file....
This other plugin is able to add the hook: https://github.com/rossmartin/cordova-uglify
postinstall
in package.json https://github.com/rossmartin/cordova-uglify/blob/master/package.jsonAlso, you guys use ruby..... if possible it would be better if you guys used nodejs since it's more used...
Thanks!
This issue seems to be old, but is still present, please fix?
I get getCordovaIntent() to work but setNewIntentHandler does not work when it is shared with the application. Has anyone experienced the same problem or has a real example about how to implemente setNewIntentHandler() ?
Hi, when the app it´s completly closed (cold start) i try to share an image or a text using this plugin and it don´t work.
When the app it´s open on background the plugin work perfect.
Somebody have this problem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.