Phonegap: Can't get Email Composer to work - javascript

I've spent a couple of days trying to implement emailing functionality to my app, but I can't get it to work.
I'm trying to use the plugin (or plugins, as description claims) from here: https://build.phonegap.com/plugins/705
I've added the following code to my XML file:
<gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.1" />
Then for testing I created a simple page with a simple code, just to see how it would look. Here is how my JS piece looks:
document.addEventListener('deviceready', function(){
$('#composertest').click(function(){
alert('tapped');
window.plugin.email.isServiceAvailable(function (isAvailable) {
if (!isAvailable){
alert('Service is not available');
}else {
alert('Service is available');
}
});
window.plugin.email.open();
alert('worked(?)');
});
}, false);
The weird thing is that I get both alerts "tapped" and "worked", so if there would be an error, the last alert shouldn't be executed. However I don't get any popup or new window, the plugin seems to do nothing. Alerts about the service don't fire. I've tried to return the type of window.plugin.email in alert and it wrote "Object", so it is not undefined.
I've tried so many things now (including other plugins) that I'm completely lost with clues. Last time I tried to remove JQMobile, but it didn't change anything. Right now the code is very simple and uses as few files as possible and still it doesn't work. I've also tried to make a lot of changes in the code (and also tried the exact example from the docs page) and never got to the point where plugin does anything.
Am I missing something? Is there a working example somewhere?
PS: Phonegap debugger doesn't return any errors, although I don't trust it too much, since it's quite buggy.

If you just want to send a mail within PhoneGap you can just use mailto URI scheme.
Here are some links:
http://css-tricks.com/snippets/html/mailto-links/
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_mailto
This will send an email intent in Android then the user can choose which app to open the mail in.

Related

Html5 audio tag not working in Local IIS for Google translate_tts

Trying to use google's translate_tts as my fallback if the browser doesn't support speechSynthesis for my project.
Now I am having some trouble with getting the html5 audio working properly.
Been scratching my head and googling all day on why it wasn't working for me.
Then I came across some articles/forums saying that it's something to do with IIS. So I did a test code outside my site to see what happens, and was surprised this worked properly! But when using the same code in my original project which is running in IIS it doesn't work. AND it works when using IIS EXPRESS. I check the MIME types in IIS and mpeg and mp3 are there.
Even doing it in javascript doesn't work in IIS.
TextToSpeech.Audio = document.createElement("AUDIO");
TextToSpeech.Audio.src = url;
TextToSpeech.Audio.playbackRate = 1;
TextToSpeech.Audio.preload = 'auto';
TextToSpeech.Audio.volume = 1; // 0 to 1;
TextToSpeech.Audio.addEventListener('ended', function () {
//i have some code here...
});
TextToSpeech.Audio.addEventListener('error', function (error) { });
TextToSpeech.Audio.play();
Has anyone encountered this issue and happened to resolve it? Your help will be much appreciated, Thanks!
UPDATE: After some more googling, this might be because I am calling it from within my site hosted in IIS which has a proper hostname and my IIS Express runs the site in localhost:PORT which Google sees as noreferrer?
starting some time in the last few days, google seems to have placed a 'captcha' on this service and made it so that it can no longer be called by a server. so this may all be moot.
it used to be you could ONLY call it as a noreferrer, so i don't think noreferrer is your issue (or may be the least of your issues starting a few days back). one way to workaround the issue in fact was to add ref='noreferrer' to your link.
and this may be your initial issue: using wget, you had to use the -U Mozilla option which makes wget appear to be a browser. if you called the url without that, it didn't return anything. so if there is a way to make your IIS look like a browser when calling the google url, that may work.
this link google text-to-speech artile still does work in a browser, maybe that will help you use it the way you want.
however... starting july 28th, i get a '503 service not available' after using it for years with wget on my linux server. could be because it's metered and i've overrused it... i hope it comes back on. i only use it about 100x/day.
they always said it was 'not public' but it is widely used that way...
so that could be related if you're still trying to call it from IIS which i would think behaves similarly to calling it from a linux server.

HashNavigation in cordova wp8 hangs app

I have next code
function navigate(_hash){
alert('before');
//try#1
window.location.hash = _hash;
//try#2
// window.location.href=window.location.href.split("#")[0]+"#" +url;
alert('after');
}
navigate('someurl')
the issue is that after changing url hash (both variants) app just hangs. And interesting thing that second alert is not firing. so app just... crashes after some time.
Nothing in js console.
Debug log says
The thread 0x*** has exited with code 259 (0x103).
google found nothing on that. Seems like this is acommon error code.
More details:
i'm using ChaplinJs so just can't get away from hash navigation.
second thought was that chaplin overloads system and we caanot get anywhere, but(!) putting logs and alerts in source of lib in window.on('hashchange',....) also didn't make any effort because we do not get there also.
WP 8.0
tried both Cordova 4.* and 5.*
also tried to modify xhrXelper.cs but it is not related tonavigation itself.
PS: I know that jquery mobile suggests to disable hashchanges onmobile navigation. But i can't :(
PPS: also tried todisable chaplin haschanges
new App({routes: routes, controllerSuffix: '-controller', pushState: false,hashChange:true})
but this also didn't make any good results because it's placing hash to href to check it in interval and app hanged again. So i assume that is a webview problem
More additional info:
continious re-run of app makes it work sometimes (1 run of 10 can make it work). That's very strange.
Emulator and device behave in the same way.
Update: Read somewhere that it's critical to restrict navigting before "deviceready" event.
But this is also not a case.
Update2: create cordova proj from scratch. Added hash change indeviceready cb and it hangs
Update3: same code on 8.1 works perfect

Is it possible to use actual image from Phonegap plugin Canvas2Image?

I am using the Phonegap plugin Canvas2Image: https://github.com/devgeeks/Canvas2ImagePlugin and I was wondering if it would be possible to get the rendered image in the callback?
I am using the code out of their documentation:
window.canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
console.log(msg);
},
function(err){
console.log(err);
},
document.getElementById('myCanvas')
);
This works great to save to the library as intended, but if I want to use the actual photo.png or whatever is generated, can I do this? If not, is there a way in the callback to get the local filesystem URL to the image?
The first function, with msg in the parameter, is going to be your file URL. However, it only is calling back on android. IOS is not working at this time. On the github site, there is an open issue on the matter. I haven't verified it, but someone said that iPhone: How do I get the file path of an image saved with UIImageWriteToSavedPhotosAlbum()? helps to fix the issue.
Github issue: https://github.com/devgeeks/Canvas2ImagePlugin/issues/38

How to display error (text/html) response to an AJAX/getJSON request?

My situation is, I'm developing a little web app where the server provides dynamic JSON responses. The server is built on cherrypy. Sometimes, there is a bug in the code creating the JSON data, which throws, and cherrypy catches it and serves back a 500-error with a full HTML page detailing the exception. (That is, the response has everything: <!doctype..><html><head>...</head><body>...</body></html>)
But because the request is AJAX, it doesn't get displayed.
I can intercept this error easily enough, and look at it in the dev tools; but what I'd like to do (to ease debugging) is open a new page (as if user had followed a link) and display that response in the browser. I tried
window.open('', '_self');
$(document).html(jqXHR.responseText);
but I just get a blank page. I suppose I could store the error text and serve it up in a second request to the server, but is there a cleaner way?
To follow up, the final code that worked was this:
.error(function(jqXHR, textStatus, errorThrown) {
$(window).bind('unload', function() { document.write(jqXHR.responseText); } );
var win = window.open('', '_self');
return false;
});
Not sure if that final return false is necessary but it seems good form.
Following up again: the above code worked reliably in Opera. I thought I had seen it working in Webkit as well, but I started noticing that it wasn't; and on further testing, it wasn't working for Firefox either.
What I found that worked in all three platforms was this:
document.open('text/html', true);
document.write(jqXHR.responseText);
document.close();
Don't have to open another window or bind events; just re-open the document and stuff the text in there.
Well, here I am again. The above technique either stopped working or I was tripping when I said it ever worked at all. Chrome, in particular, doesn't seem to have document.open defined.
But! I just found a nifty technique that seems to work everywhere:
errtext = 'data:text/html;base64,' + window.btoa(jqXHR.responseText);
window.open(errtext, '_self');
This simply converts the response into a fully self-contained data: URL and opens it in the window.
Try this:
var win = window.open('', '_self');
win.document.getElementsByTagName('Body')[0].innerText = jqXHR.responseText;

SWFUpload ASP.Net example site not working?

http://swfupload.org/node/7/release
The .Net 2.0 sample is not working, has anyone faced the same thing and have been able to make it work?
The solution is compiling and the default page is opening normal in FireFox but when I click on the button nothing happen, and in IE the button is not appearing at all
A few things note with the SWFUploader is that although there is a .Net test project it is a little miss leading and does a lot more than is really required, its great if you want to upload images but dosn't have the progress bar or allow file uploads.
Make sure you get the source code form http://code.google.com/p/swfupload/ not the site, this will fix any issues you have with version 10 / 11 of flash not working.
To get any of the PHP demo working with .Net just make a file called upload.aspx to replace the upload.php with the following code in.
try
{
// Get the data
HttpPostedFile postedfile = Request.Files["Filedata"];
postedfile.SaveAs(Server.MapPath(".\\") + postedfile.FileName);
}
catch
{
// If any kind of error occurs return a 500 Internal Server error
Response.StatusCode = 500;
Response.Write("An error occured");
Response.End();
}
finally
{
Response.End();
}
Change the the default page name to html or .aspx and change the call inside to your new save script.
It will now save the files in the root of the website.
I was having this issue but what fixed it for me was getting the newest version of the swfupload controls. I didnt realize that the stuff you download off google source had the .net stuff in it as well, i was using the out of date controls off the .net page on their website.
if you go to http://code.google.com/p/swfupload/ get the "SWFUpload [version number] Samples.zip" and it has .net stuff in it, which i was able to get working just fine.
i got it, because my Flash version is 10 and SWF is not working with Flash player 10 as its not allowed in Flash player 10 to call a swf file, so the solution for that i putting the object its self on the page and make it as a button to make the user click on the object its self.

Categories