Skip to content
This repository

Cannot launch mail client using mailto: in Tablet OS 2.0 #53

Open
astanley opened this Issue March 06, 2012 · 39 comments

10 participants

Adam Stanley Ken Wallis Muerl crwblyth sdragomir Matt Lewandowsky Frank Tony Cheung joeljesudoss
Adam Stanley

The browser supports the mailto: scheme, but WebWorks applications running on Tablet OS 2.0 do not.

Ken Wallis
Owner

Is this widely used in WebWorks apps?

Adam Stanley

Yeah I think so - I'll try to add facts here to this thread.

Should have added a link!

Discussion about this in the forums:
http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/PlayBook-mailto-lt-recipient-gt-fails/td-p/1591465

Have also received a request via BBM from Kathryn (Larhs).

I'm seeing more and more interest in this, especially now that Tablet OS 2.0 has launched and there is a native email client.

Ken Wallis
Owner
Adam Stanley
Muerl
muerl commented March 09, 2012

As an ISV dev I vote for this issue.

Actually I would vote for any PIM integration in webwork on tablet ASAP.

crwblyth

This is definitely needed by me!

Muerl
muerl commented March 12, 2012

astanley are there PIM APIs for other development platforms? IE Native or Flash?

Adam Stanley

No there is currently not. Its on the product management roadmap for future platforms. However this capability cannot currently be achieved through a WebWorks extension.

Muerl
muerl commented March 12, 2012

Is there a JIRA issue I can go vote for ;)

It is surprising that the "mailto" feature is still missing in WebWorks for PlayBook OS 2.0. The sooner this bug is fixed, the better. It would be great if it allowed the WebWorks app to programmatically attach a document to an email message and send it using the native email app.

sdragomir

Same problem here: mailto: works in browser, but not in the packaged webworks app (instead of launching native email application a javascript alert is displayed, with the contents of the mailto:, plus "is not allowed" at the end. I tried specifying in the config.xml file, to no avail. Please advise.

After some API digging I figured out a simple way to send an email from a WebWorks app using the native email client. But then I wonder why there is no response from the dev team on this issue.

Muerl
muerl commented April 11, 2012

Would you share with the posterity please?

Well, in case I am missing something then maybe someone can improve this code. Here goes:

var remote = new blackberry.transport.RemoteFunctionCall("blackberry/invoke/invoke");
remote.addParam("appType", "mailto:?Subject=SubjectStr&body=" + encodeURIComponent(BodyStr));
remote.makeAsyncCall();

mailto: can be followed by an email address. String SubjectStr must not contain space characters, use %20 instead. Or use encodeURIComponent() like I did for BodyStr.

Muerl
muerl commented April 11, 2012

Interesting. Looking at the code I understand why this works, though I am surprised that its not an understood thing if it does work that way.

This implies that

 net.flash.navigateToURL.navigateToURL(
    new URLRequest("mailto:?Subject=SubjectStr&body=" + encodeURIComponent(BodyStr)));

will work the way described as well, which means there is a hidden backdoor AS api as well.

GOOD find!

Thanks.

Muerl
muerl commented April 11, 2012

After thinking about this a bit this means that there must be some addressing inside Air to other applications which is not well documented.

I am curious why this didn't seem to work for me from my JSConsole App when I tried blackberry.invoke.invoke('mailto:haagmm@gmail.com')

Matt Lewandowsky

Just popping in... I don't really use WebWorks, but are you saying that it doesn't support the standard PIM APIs, including the messages:// URI scheme?

https://bdsc.webapps.blackberry.com/native/reference/com.qnx.doc.bps.lib_ref/com.qnx.doc.bps.lib_ref/topic/navigator_invoke.html

Note that the PIM API doesn't currently allow file attachments, though. See JIRA issue TABLET-550 for the bug regarding that. :/ https://www.blackberry.com/jira/browse/TABLET-550

Muerl
muerl commented April 11, 2012

lewellyn rock on. It seems Adam is totally wrong, which is good because these features rock.

Now time to work on some JS magic so the handheld APIs work.

sdragomir

@lewellyn I know you said you don't use WebWorks, but do you happen to know how would I call navigator_invoke() from an htm page (WebWorks application)? Anyone?

Muerl
muerl commented April 12, 2012

@sdragomir I believe that what we saw @lcocea showing off means that the blackberry/invoke/invoke api hook which calls net.flash.navigateToURL.navigateToURL seems to be implemented in AIR by calling navigator_invoke(). Hence anything you pass into the invoke API winds up resolving to the linked API page.

sdragomir

@muerl that's great, but I could not find anywhere information about how to actually call that from htm. Assuming the code @lcocea shared is javascript, what is 'blackberry' in the context of the following line:
var remote = new blackberry.transport.RemoteFunctionCall("blackberry/invoke/invoke");

Is that defined in a javascript library that has to be specified as a feature in my application's config.xml? What feature?

Muerl
muerl commented April 12, 2012

You need to add blackberry.invoke to your config.xml.

<feature id="blackberry.invoke"/>
sdragomir

That worked! Thank you!

Frank

Thank you @lcocea ! Very helpful. I'm wondering where was blackberry.transport.RemoteFunctionCall documented?? I can't find anything on that or how it works

Muerl
muerl commented April 25, 2012
sdragomir

There seems to be a message length limit of 1000 (or so) bytes? I'm getting an error 7 on the PlayBook and I was able to determine it has to do with the message length... If that's the case, is it like that by design? Can the limit be increased?

Did you try to catch the exception and see what the message reads?

sdragomir

@lcocea I don't know how to read the error from the RemoteFunctionCall... I cannot find the documentation for it. Could you please share if you know how that's done?

Thanks!

You could try this:

try
{
// your code here
}
catch (e)
{
alert(e.message);
}

It probably won't work for the async call part but it may be informative if the exception occurs before that statement.

Muerl
muerl commented April 30, 2012

The exception seems to be raised at the last statement, remote.makeAsyncCall(). I am just speculating, I am off "my reservation" here, so I could be wrong -- I think the argument string for function makeAsyncCall() is too long if length(SubjectStr + BodyStr) is greater than ~1K. Statement alert(e.message) also doesn't run: my PlayBook says "Can't start Messages due to an Error 7". Error 7 description on Unix is something like "arg(s) list too long". We need the API to support email attachments for larger email messages.

sdragomir

Thank you for the info. I'll shorten the email message for now and will change it back once the API will have support for attachments. By the way, I still cannot find the documentation for RemoteFunctionCall... I don't know what I would have done without the help from this forum. The online documentation is inadequate, when it's not missing completely, to say the least.

lcocea commented May 01, 2012

I agree. But this is common for open source projects. This is one reason why I plan to do most of my BB software development in NDK/Cascades after I publish my next WebWorks app.

Tony Cheung

Is this issue fixed with PlayBook 2.1.0.560? Thanks.

joeljesudoss

Hi

I want to send an email with attachment in Playbook using webworks(my existing app is in webworks)
Is there any way to achieve this?

The workaround suggested are with character length limitations and also doesnt support attachments.

This thread in github and the thread

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-send-Email-in-Playbook-using-web-works/td-p/1475779

have been going for more than 2 years, please give a solution, any method is fine, it should be supported by webworks in Playbook thats all.

Please help

Thanks
-Joel

joeljesudoss

SOLVED :D but other problems :(

There is a workaround to invoking mail attachment in playbook,

Use phonegaps webintent.js plugin and webintent.java

And create an apk by building with android sdk

finally convert the apk to bar using hatax apk2bar

now run the bar in playbook and voila, it invokes mail client with attachment :)

I checked on playbook OS 2

But there are still issues with permissions on ajax calls, I am gettin Network error on ajax call for POST on playbook, whilst the ajax is workin fine in android

I have posted the issue here http://supportforums.blackberry.com/t5/Android-Runtime-Development/XMLHttpRequest-Exception-101-APK-to-BAR-file-Conversion/td-p/2166063

pls help

Thanks Regards
Joel

joeljesudoss

Hi is there a way to get the source code of hatax apk2bar. I tried googling but couldnt find the source code, there is only apk2bar.jar, Is there anyway to contact the developer of apk2bar.jar? If I can get hold of the API they are using to invoke the mail client with attachment, then i could probably use it directly in my webworks and generate a bar instead of building an apk and converting to bar.

pls help

Regards
Joel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.