April 2014 update: we have moved the project and packaged it with a sleek manual on our new website, along with a sleek manual and demo video. Check it out: http://easynativeextensions.com/product/diadraw-e-mail-ane/
Do you remember the olden days, when Adobe AIR and Apple’s iOS didn’t seem to play nicely, when it came to orientation?
Right. Well, that was only a few months and a couple of AIR releases ago, but since then Adobe have fixed their stuff and so we have updated our e-mail extension to reflect that.
Many of you contributed with feedback and ideas to our previous post, Native extensions for mobile AIR apps – getting round the orientation issue – thanks go to all of you! Special thanks to Nicolas Jauffret for alerting us about orientation issues with the new Adobe AIR SDKs and to Dave for letting us know that messages were not received by ActionScript!
Where’s the ANE?
April 2014 update: we have moved the project and packaged it with a sleek manual on our new website, along with a sleek manual and demo video. Check it out: http://easynativeextensions.com/product/diadraw-e-mail-ane/
What’s new?
1. Code has been updated to work with Adobe AIR 3.4 and iOS 6.0
- Built using Adobe Flash Builder 4.6 with Adobe AIR 3.4 and XCode 4.5 with iOS SDK 6.0
- Tested on an iPhone with iOS 6
2. No more orientation mumbo-jumbo
For those of you who will build the extension from scratch, the workaround is still there, but disabled. Uncomment the following line in MailComposerDelegate.m, if you use the extension with Adobe AIR 3.2 or older:
[sourcecode language=”objc”]//#import "UIViewController+Orientation.h"[/sourcecode]
For details on how and why this works, have a look at our initial post: Native extensions for mobile AIR apps – getting round the orientation issue.
3. Optional HTML in the body
The extension initially was set not to use HTML at all – thanks to Chuck for his feedback on that!
We added an optional Boolean parameter to the sendMail function, so you can set from your ActionScript whether the e-mail body will have HTML turned on or off. The parameter is optional and is TRUE by default, so even if you don’t include it explicitly, your old code should still work.
For example use of sendMail have a look at FlexApp/src/views/TestEmailAppHomeView.mxml:
[sourcecode language=”actionscript3″]
m_mailExtension.sendMail
( subject,
body,
toRecepients,
ccRecepients,
bccRecepients,
[attachmentStr],
useHtml );
[/sourcecode]
4. Bug fix: not all messages from the native side were received by the ActionScript side
… and the moral of the story was: mind your variables’ lifelines! Looks like native code wasn’t holding on to the ExtensionContext instance for long enough, so any asynchronous messages that were sent after the mail composer was dismissed were lost.
Thanks to Dave for alerting us to the problem!
Let us know what you think
The community has been wonderful about providing feedback and alerting us to problems. Keep ’em coming! You can post comments here or get in touch with us directly via office@diadraw.com.
Hi,
This is great example for native extension to send mail and good way to prevent orientation issues, I had the original mail extension code off flashsimulations.com, it was working great until I upgraded my iOS SDK to 6.0, it is throwing the below linker error, any help greatly appreciated.
ld: illegal text-relocation to ___stack_chk_guard in /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/libSystem.B.dylib from -[MailComposerDelegate sendMail:toRecipients:ccRecipients:bccRecipients:messageBody:useHtml:attachmentsData:] in /var/folders/mg/vp5t6tx90t7gdy388cztchx00000gn/T/43a1899a-e22d-48d4-b404-833b861e9b41/libcom.commvault.NativeAPI.a(MailComposerDelegate.o) for architecture armv7
Compilation failed while executing : ld64
What does this mean exactly ? and how do I resolve it ?
Hi Ked,
I’m glad you are finding our e-mail example useful.
It would be hard to tell why you are getting the linker error without knowing what your project settings look like. However, you could try this: add the following option to your platformoptions.xml file (under the linkerOptions tag):
[sourcecode language=”xml”]
<linkerOptions>
…
<option>-read_only_relocs suppress</option>
…
<linkerOptions>
[/sourcecode]
Let me know if this works for you.
Radoslava
Hi
I need to send an attachment via e-mail client programatically in playbook using webworks sdk(existing code is done using webworks sdk)
I had implemented it in BlackBerry Curve using Java Extension in webworks sdk
But Jave Extension is not getting recognized in PlayBook emulator – am getting errors while building
Also I went through the post in
http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-programatically-send-email-using-Playbook-2-0/td-p/1612515/page/3
But there is no solution to add mail attachment
Also is it possible to use AIR extension as given in this post, for the mail attachment in PlayBook webworks
If possible could you give me the steps?
Also if there is any other way to send mail attachment in Playbook using webworks, please share it with me.
Thanks
Regards
Joel
Hi Joel,
The current extension only supports Apple iOS, so unfortunately you can’t use it out of the box for BlackBerry.
To make it work, it will need the native BlackBerry implementation added to it the same way the iOS Objective-C implementation was.
Are you a BlackBerry developer? If you would like to contribute a native implementation for that, we’d be happy to add you to the googleCode project.
Thanks,
Radoslava
Nice extension, but does it support multiple attachments?
Hi Ivan,
It does. You pass an array with information for each attachment to sendMail() – more details here: https://code.google.com/p/diadraw-air-email-native-extension-example/
Cheers,
Radoslava
Hi,
I’m including the ANE in my AIR for iOS build in Flash Pro CS6.
I’m running on a windows 7, and when I attempt to compile and run with the ANE included I get the following error:
Requested extension com.diadraw.extensions.email.NativeEmailLauncher is not supported for Windows-x86.
I can see that it is only compatible with iOS, but it seems odd that even before I call any of the functions (i’ve only included the ANE at this point) that it should fail the entire app?
Anyway around this?
Thanks
Mike
Hi Mike,
You are right, the ANE will only run on an iOS device. When there isn’t an implementation that the project can reference for the simulator on Windows, you would typically get this error message.
A way around this would be to add a default implementation and rebuild the ANE. This would be a parallel AIR library (you won’t need a native implementation) that just stubs out the methods that are implemented in NativeMailWrapper.as (https://code.google.com/p/diadraw-air-email-native-extension-example/source/browse/FlexEmailLib/src/com/diadraw/extensions/mail/NativeMailWrapper.as) and MailExtensionEvent.as.
Hello Radoslava, I am using this native extension with IOS 6.1.3 into an IPad and isSupported returns “false”. Is it not compatible with this IOS version?
Thanks!
Hi Manuel,
Could you paste the code where you call isSupported, so we could see it in context?
Thanks,
Radoslava
Hi,
I’m using the in-app mail composer in the latest iOS7 beta on iPhone5: mail is sent, but the dialog is not disposed of. Same thing happens when I cancel an email.
–> I think the extension needs a slight update for iOS7: the guys from MilkMan who run the GoViral extension have also updated their email bit to change the hiding of the dialog after sending.
(I prefer your extension to theirs though: they use bitmapData as attachment and they compress it too much for sending graphics. I encode my own bitmapdata and use your extension to send the encoded JPG.)
Thanks for your great work!
Hi Sander,
Thanks for the heads-up!
We are about to release a new website, where we’ll move the current extensions we’ve published and add a few more. We’ll see to update them all to work with the latest iOS and AIR versions.
Stay tuned: http://easynativeextensions.com
Cheers,
Radoslava
I am currently working on a project in FL CS6 using your extension to send an email with an attached PDF that is create by the app.. I have tried mime types of “application/pdf” and “application/octet-stream” but both produce an email that shows a pdf icon and the filename, but there is no attachment on the received email.. (Device is on iOS 6.1.4) All else is working perfect.. Any ideas what else I can look at?
Thank you!!
Hi Chris and apologies for the late reply!
Sounds like what you are doing is correct: “application/pdf” should do as a mime type for attaching PDFs. Another thing you may want to check is the path to the file – it should be an absolute path (the kind that file.nativePath() would give you) and contain the file name. I suspect you’ve got that right too, though, as you can see the file name in the outgoing e-mail.
If that doesn’t help, feel free to post the code that calls sendMail() and I’ll see if I can reproduce the problem here.
Cheers,
Radoslava
Hi Radoslava,
This is so use full ANE from you thank you for this and just wanted to inform you that i am also facing the same issue as ‘sander’ with iOS 7 its not disposing off when we hit ‘cancel’
with Regards,
Chirag
Hi Chirag,
Thanks for adding your voice too, it’s good to know how many people are experiencing the same problem.
Stay tuned for the updated extensions on the new website: http://easynativeextensions.com/
Cheers,
Radoslava
Hi,
I notice that you used to code in Delphi.
I am looking to be able to write NativeExtensions for Adobe AIR but I do not understand C but I know Delphi very well. Do you think it would be difficult for someone to convert the C to Delphi style to allow me to code extensions in my favorite language ?
Hi Antoni and fellow Delphi fan,
That’s an interesting idea.
I guess that would either require Adobe to release a Delphi version of their native extension API or someone to write a Delphi wrapper around the already published C API. Not necessarily a trivial or quick task.
What kind of projects are you doing in Delphi?
Cheers,
Radoslava
Hi Radoslava,
Another user of your great ANE here. Much appreciated!
Just wanted to confirm that I’ve also encountered the iOS7 issue Chirag and Sander above stated re: “disposing off when we hit ‘cancel’”. Any estimate on when you might be launching your new site with (hopefully) a fix for this ANE?
Thanks heaps!
Many thanks to all of you who got in touch to tell us that the iOS 7 update broke our e-mail ANE.
We are still working on moving our existing extensions to the new website and preparing it for the grand opening.
However, we thought an iOS 7 fix for the e-mail native extension is due and should come out sooner.
So there you have it: http://diadraw.com/e-mail-native-extension-ios-7-fix/
Thanks again,
Radoslava