downloaded fileopen plugin for Android here (https://github.com/markeeftb/FileOpener)..set it up per instructions for plugman compatible & doesn't work.
Tried adding files to this post but every time I select attach files the page reloads and I lose everything (??). Fix this up & I'll add the 2 zip files.
Also added the line to index.html
<script type="text/javascript" src="Plugins/www/fileopener.js"></script>
and also tried
<script type="text/javascript" src="fileopener.js"></script>
but got a file not found error.
14 Answers, 1 is accepted
You can try using this fork of the plugin. It already has a valid plugin.xml and is updated to work against Cordova 3.0.0. Just add the plugin files to your project. You do not need to add <script> references to your index.html.
However, in plugin.xml, change line 15 to <clobbers target="plugins.fileOpener" /> Otherwise, the plugin does not work as expected.
Iva Koevska
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
did as you suggested and installed everything.
Tried to run the plugin
window.plugins.fileOpener.open('file:///sdcard0/theFile.pdf')
and get windows.plugins undefined
Read that "plugins" has been depreciated in 3.0 so ran
window.fileOpener.open('file:///sdcard0/theFile.pdf');
and get error Cannot call method 'open' of undefined
Something is going wrong...do you have a sample app that you can show me?
Attached you can find a very basic example which opens an existing photograph on your sdcard. Just make sure that the file path to the image is correct. Check this documentation article as how to recreate a project from archive.
Here are a few suggestions that might help you identify your problem.
- Do you have the cordova.js references in your index.html file? They should be on the top of your includes.
- Do you initiate a deviceready event in your code? It should be the first thing your app does. Without it, you won't be able to run any Cordova functionality.
- Are you testing on a physical device as custom plugins do not work in the simulator?
Basically, calling a custom plugin in Apache Cordova 3.0.0 goes down to calling whatever you have defined as clobbers target in the js-module declaration in the plugin.xml. For example, if the clobbers target is fileOpener, then you have to call the plugin with window.fileOpener. If the clobbers target is plugins.fileOpener, use window.plugins.fileOpener, and so on. You can read more about this here.
Regards,Iva Koevska
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
thanks for that example....yes I had done all the things that you suggested but I thank you for sending the working example. I ended up deleting the test project completely and starting again...of course it works now...somewhere along the way I got something out of order but if I keep it simple it works fine.
Your example showed me the way...thanks again.
One question:
if I do fileSystem.root.name I get sdcard0...but the file is stored at file:///storage/sdcard0 & I use this path to successfully open my file...do I always have to add the "storage" to the file path?
How are you?
I have also trouble with custom plugin.
that is social sharing plugin.
I used https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
I attached the my project.
sometime, I can see "nope" alert.
if (typeof window.plugins.socialSharing !== 'undefined'){
// plugin is available
alert("okay!");
window.plugins.socialSharing.share('Message and subject', 'The subject');
}else{
alert("nope!");
}
Thanks.
We're not familiar with the SociaSharing custom Cordova plug-in and cannot be of much help for it. As the plugin is a 3rd party software, our suggestion is to contact the developer(s) of the plug-in directly in the Issues section of the github repo for more info and help on the issue you have faced.
Regards,
Steve
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
now I have the fileopener for Android (works a treat) is there a similar one for Apple...or is there a way to open files on an iPhone or iPad?
Find it here https://github.com/jwark/FileOpener/tree/cordova-3.0
*** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit/UIKit-2903.23/UIDocumentInteractionController.m:1010
this is the file path
/var/mobile/Applications/CAEAF24F-AFA6-48CA-B5BB-88FEBA383DD8/Documents/07f83cb8-07d2-44d8-82c3-be1b12dd1a80.pdf
You do not necessarily need a plugin for iOS to open various types of files, take a look at this forum thread for more info and sample project.
Regards,
Steve
Telerik
tried out your example and it won't work on Android (Galaxy S3 V4.2) !!!! Works on iPad though.
Tried changing the window.open(path, '_system'); to window.open(path, '_blank); & get a "Wepage not available" error.
The original path is file:///storage/emulated/0/sample.pdf but the webpage comes up with
file:///storage/emulated/0/icenium/com.telerik.DocumentOpener/undefined.
The original _system command gives nothing...like dissapears into a black hole...could use this method with the Android plugin to cover apple though
BTW I created a new app from the zip file & didn't just add bits to my original app.
I've tested on several Android devices including Galaxy S3 with Android 4.1.2 and the sample works on all of them. For Android, you should use
_system
and not _blank or _self.Regards,
Steve
Telerik
glad it's working for you but it isn't for me...am using _system and activity just stops at this line...I don't know why and everything else is working.
The Android plugin for file opener is working and I don't have the time to try and find out why it fails on Android (it does fine on Apple) so I'll stick with the Android plugin.
I am finding more and more with the hybrid/cordova scene that it depends how high you're holding your leg when you type the code in rather than what you're actually typing...there is so much going on with frameworks,plugins, callbacks etc that getting something to work is more a happy accident than a science.
thanks for your help in getting the Apple side of things to work
If you have the time, you could debug on device to see what goes wrong, see Debug on Android Device.
If that does not help you can setup Fiddler to log the device traffic, which would give you a clue what's going on if the problem is failing/wrong requests/responses.
Regards,
Steve
Telerik