709 - sending email

local function onTap(event)  
 native.showPopup("mail", {to="rob@robmiracle.com", from="rob@omnigeekmedia.com", subject="How Now Brown Cow", body="The rain in Spain falls mainly on the plain!", isBodyHtml=false})  
end  
local btn = display.newRect(100,100,100,100)  
btn:setFillColor(255)  
btn:addEventListener("tap", onTap)  
  

I know we don’t have much more than the release notes to go on, but based on what I read, that code should work.

Am I missing something? I’m not getting the popup at all. Any one gotten this new feature to work yet?
[import]uid: 19626 topic_id: 19297 reply_id: 319297[/import]

Same here I am getting this

Dec 17 13:27:33 unknown UIKitApplication:xxxxxxxxxxxx[0x34ca][983] <notice>: Lua Runtime Error: lua_pcall failed with status: 2, error message is: attempt to index a nil value<br> [import]uid: 22829 topic_id: 19297 reply_id: 74430[/import]

I haven’t tried this feature for myself yet, but here is how it is currently documented on our side. (Please note that this is subject to change.)

[lua]-- NOTE: This is pseudo code. Please do not blindly paste it into your Lua code. :slight_smile:
local mailOptions = {
to={ “a@z.com”, “b@z.com” }, – required (string or, for multiple, array of strings)
cc={}, – optional
bcc={}, – optional
attachment = { baseDir=, filename= [, mimeType=] }, – optional (single element or, for multiple, array of them)
body="",
isBodyHtml= true/false,
subject="",
listener=,
}
native.showPopup( “mail”, mailOptions )[/lua]

I believe the “to” field is currently required (I’m thinking it shouldn’t be, but that’s how it is at the moment). It looks like it supports a string or string array. Try putting curly braces {} around your “to” field as shown above in case Corona currently expects it to be an array.

The “from” field is not supported. So please remove that from your table. The from field will be set to the e-mail account set up on your iOS device.

Hopefully, this will be enough to get you started. At least until we can get real documentation and a sample app written up for this. [import]uid: 32256 topic_id: 19297 reply_id: 74435[/import]

I’m continuing to work on this (though to be honest I’d much rather be playing around with push notifications…)

Anyway, here’s my current code:

local btn  
  
local function onSent(event)  
 btn.text = "Sent"  
 return true  
end  
  
local function onTap(event)  
 btn.text = "Sending"  
 local mailOptions = {  
 to = {"rob@omnigeekmedia.com"},  
 subject="How Now Brown Cow",  
 body="The rain in Spain falls mainly on the plain!",  
 isBodyHtml = false,  
 listener=onSent  
 }  
  
 native.showPopup("mail", mailOptions)  
 return true  
end  
btn = display.newText("Send Message", 0, 0, "Helvetica", 24)  
btn:setTextColor(255)  
btn.x = display.contentWidth / 2  
btn.y = display.contentHeight / 2  
btn:addEventListener("tap", onTap)  

Tapping on the text does indeed fire the onTap function because I see the text change to “Sending”, but I don’t get anything else after that. It’s almost like I’m running it on the Corona simulator. Which of course the lightbulb just went off… check for error messages on the console:

[0x226c][14396] : Lua Runtime Error: lua_pcall failed with status: 2, error message is: attempt to index a nil value

So I got the bright idea to provide all the parameters and VOLIA! It worked… sort of.

I got the email popup and was able to send the email which I did receive. But my call back didn’t fire or else it errored, though I didn’t see anything in the console log to indicate an error as my text never changed to “Sent”.

Anyway, progress. I don’t know which parameter its actually expecting that I didn’t provide.

But happy email sending folks!

[import]uid: 19626 topic_id: 19297 reply_id: 74448[/import]

Yes you must supply all parameters (including attachment). Here is my code:

native.showPopup("mail", {to={"myemailaddress@gmail.com"}, subject="Feedback", isBodyHtml=false, body="hello", attachment={}, listener=function(event)  
 print(json.encode(event))  
end})  

However the listener function isn’t being called, maybe it is named something else…

So yes, just specify every var. It should check for null to make it more user friendly.

Thanks Ansca! [import]uid: 22829 topic_id: 19297 reply_id: 74459[/import]

I’m glad you guys got it working. The mail API should definitely not crash if your table is missing entries. Especially since it should be okay to leave some table entries empty for the end-user to fill in. So, that sounds like a bug to me. What I posted up above is from the original specification before the mail API was written, so hopefully it is still applicable. Especially in regards to the listener.

This is the very first version of the mail API and the rest of the Ansca team hasn’t had a chance to play with it yet. That includes me. You’re quite literally working on the bleeding edge. So, don’t judge it too harshly just yet. If you find any issues, please feel free to post them here on this thread. There’s no point in posting any bug reports until the official API documentation is made public. But hey, this is your chance to speak your peace on this feature while we’re still tinkering with it! :slight_smile: [import]uid: 32256 topic_id: 19297 reply_id: 74465[/import]

Oh, no complaining. I recognize we are pushing ahead of the curve and I’m grateful that you provided us enough to get us started and will wait on the official docs before we trying to do anything production based.

Now to get a hint at the push notification calls… [import]uid: 19626 topic_id: 19297 reply_id: 74467[/import]

Rob, unfortunately I don’t know the details of our push notifications feature yet. I do remember hearing shouts of victory when our iOS developer got it working last week though. :slight_smile: I believe the team wants to be more careful on how to document this feature since it requires a web server on the Corona developer’s end to handle the transactions with Apple’s servers. So, testing it wasn’t straight forward. I would expect a blog post on this topic sometime in the near future.

Hoan, it’s funny that you’ve mentioned SMS. I saw our iOS developer dabbling with it at the same time he was working on email support. Cross your fingers!

I’ll be working on adding e-mail support to Android this coming Monday. So whatever issues you find, I’ll make sure that they get taken care on both platforms. Thanks! [import]uid: 32256 topic_id: 19297 reply_id: 74486[/import]

Yea, I’ve got an SMS app I’ve been working on in Objective C that has been nothing but a struggle because, well its Objective C and the insanely over complicated SDK. I can probably knock this out in Corona SDK in a couple of days . . . if I can send SMS.

[import]uid: 19626 topic_id: 19297 reply_id: 74558[/import]

Hey
The listener is not working and not getting any events when sending the email and you do not need to provide data or null for all parameters, you don’t for the listener anyway :slight_smile:

This small text works perfect:
[lua] local group = self.view

– create a white background to fill screen
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor( 0 ) – white

local btn
local function onTap(event)
btn.text = “Sending”
mailOptions = {
to = {“andreas@10fingers.se”},
subject=“Testing in 10Fingers labs”,
body=“The labrat is testing another new build feature!”,
isBodyHtml = false,
attachment={}
}
native.showPopup(“mail”, mailOptions)
btn:removeEventListener(“tap”, onTap)
return true
end

btn = display.newText(“Send Message”, 0, 0, “Helvetica”, 24)
btn:setTextColor(255)
btn.x = display.contentWidth / 2
btn.y = display.contentHeight / 2
btn:addEventListener(“tap”, onTap)
group:insert( bg )
group:insert( btn )[/lua] [import]uid: 22737 topic_id: 19297 reply_id: 74862[/import]

Everyone,

I looked at the iOS implementation and it does not support a listener. So, that part of the specification that I copied up above is not implemented. Also, the mail API currently only supports 1 file attachment.

If you’ve found any crashes other than the one at the top of this thread, then can you please let me know? Most of the team here is out of town due to the coming holidays, so there’s been no testing on this API. I’ll see about having these issues fixed as soon as possible… before I disappear for the holidays. :slight_smile:

I’m going to try to finish the Android implementation by the end of today and have it support multiple file attachments. [import]uid: 32256 topic_id: 19297 reply_id: 74952[/import]

So we should not look for any documentation on the rest of the 707 and later features until after the first of the year?

I’ve got two weeks to pretty much dedicate to working on stuff before the day job fires back up.

[import]uid: 19626 topic_id: 19297 reply_id: 74959[/import]

Rob,

I was told that the URL schemes feature will be documented this week, but push notifications will not. Looks like some slight design changes will be made to our push notifications feature. I’ll look into updating our API documentation tomorrow.

That said, most of the Ansca team will be out next week. So don’t expect to hear much from us then. (I think some of us deserve a break anyways.) [import]uid: 32256 topic_id: 19297 reply_id: 74973[/import]

You guys deserve a good holiday break. In fact I’m surprised that you guys pushed out these updates before the first of the year.

[import]uid: 19626 topic_id: 19297 reply_id: 74981[/import]

Just to make life interesting, there is no way to tell on Android if the user has sent the e-mail or canceled out of the “Send Mail” window. I always get a “canceled” result code out of the default mail clients on Android. *sigh* [import]uid: 32256 topic_id: 19297 reply_id: 74994[/import]

Yes, I’m using intents. I’m using the standard “android.content.Intent.ACTION_SEND” for e-mail with 1 file attachment or no attachments. For e-mails with multiple attachments I’m using “android.content.Intent.ACTION_SEND_MULTIPLE”. The e-mail activity always returns a result code of zero, for canceled, even if I have successfully sent an e-mail.

On Android, I went out of my way to set up an event listener to let you know that the “Send Mail” window was closed. I wanted it to provide a property to indicate if the window was cancelled, but on Android, I have no choice but to set “event.cancelled” to false at all times. Kind of a bummer. Well, I guess this property is only going to be useful on iOS then. [import]uid: 32256 topic_id: 19297 reply_id: 75000[/import]

Everyone,

The official documentation for the new native.showPopup() function can now be found here…
http://developer.anscamobile.com/reference/index/nativeshowpopup
[import]uid: 32256 topic_id: 19297 reply_id: 75145[/import]

And there was much rejoicing!!!

I did realize, I do need one more feature… access to the address book. This would be very useful for sending mail and SMS messages!

Time to get programming…

Thank you… thank you… thank you… [import]uid: 19626 topic_id: 19297 reply_id: 75147[/import]

@robmiracle, your crash should go away in 713. The bug was occurring anytime you provide the param table but omit the attachment. This goes away in 713. All properties of the param table should be optional.

BTW, for iOS, you can access the address book UI from within the mail/sms composer popups. We’ll probably be moving to other priorities before we revisit the address book, so hopefully that covers your use cases. [import]uid: 26 topic_id: 19297 reply_id: 75200[/import]

Well I was hoping to setup a pickerWheel that had a list of your frequent contacts and it would be helpful to let the users add people to the pickerWheel from their contacts.

I’ll see what I can do with what I have. But you’re right other priorities need to be addressed first unless accessing the contacts is a quickie.

[import]uid: 19626 topic_id: 19297 reply_id: 75202[/import]