Can we not

Can we not build like a clock alarm event listener or even build an alarm clock in corona? [import]uid: 69302 topic_id: 31252 reply_id: 331252[/import]

Check out this short tutorial, it might be exactly what you’re looking for.

http://www.coronalabs.com/blog/2012/06/05/local-notifications-guide-ios/

Brent [import]uid: 9747 topic_id: 31252 reply_id: 125019[/import]

OMG Brent you are a life saver. I have been looking for some type of tutorial. Thanks a bunch!! [import]uid: 69302 topic_id: 31252 reply_id: 125021[/import]

Check out this short tutorial, it might be exactly what you’re looking for.

http://www.coronalabs.com/blog/2012/06/05/local-notifications-guide-ios/

Brent [import]uid: 9747 topic_id: 31252 reply_id: 125019[/import]

OMG Brent you are a life saver. I have been looking for some type of tutorial. Thanks a bunch!! [import]uid: 69302 topic_id: 31252 reply_id: 125021[/import]

Hello Brent,
Do you mind explaining to me how I can get that scheduled notification event listener to listen to a widget? [import]uid: 69302 topic_id: 31252 reply_id: 125451[/import]

Hi again,
I don’t quite understand what you mean by “listen to a widget”. Can you explain in more detail what your ultimate goal is?

Brent
[import]uid: 9747 topic_id: 31252 reply_id: 125456[/import]

Ok so I am going to do my best explaining. users generate lets say a message and I have a widget with a date and time that allows users to choose a specific date and time. I want the message to be sent at the specific date and time they chose from the widget. I hope that makes sense?? [import]uid: 69302 topic_id: 31252 reply_id: 125459[/import]

Hi again,
I’m actually not familiar with the whole Widget library (but I’ll be studying it soon, I think). However, the date/time widget must return some information based on what the user selects, otherwise it wouldn’t be very useful. :slight_smile: So, I assume you can gather that info and send it to the delayed notification system, correct? Again, I can’t tell you exactly how to do that in code because I haven’t looked at the Widget library much. If you can post any code here, I might be able to narrow it down or provide some advice…

Brent
[import]uid: 9747 topic_id: 31252 reply_id: 125600[/import]

Hello,
That’s where my dilemma is, no one seems to know much about the schedule event notice and now I found you who does but not familiar with the widget :slight_smile: but I am to assuming that whatever time and date the user chooses needs to somehow notify the schedule notification event listener but like you I have no idea how to code that. I can’t even find an example. I would think its almost the same as an alarm clock. But anyhow, which code so you need to see? The widget or the schedule event notification? [import]uid: 69302 topic_id: 31252 reply_id: 125606[/import]

First things first, let’s start with the widget code. :slight_smile: If you can trim it down to the basics, without alot of reference to your other code, that would be helpful (not sure how much you’ve added to it; I assume you’re using the “newPickerWheel” widget, yes?)

Brent
[import]uid: 9747 topic_id: 31252 reply_id: 125609[/import]

So, yes I am using the newPickerWheel. Here is my widget code. I haven’t done a lot to yet but this is the logistics.

[code]
local widget = require “widget”
widget.setTheme (“theme_ios”)

– create table to hold all column data
local columnData = {}

– create first column
columnData[1] = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }
–columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1

– second column (lots of rows)
columnData[2] = {}
columnData[2].alignment = “center”
for i=1,31 do
columnData[2][i] = i
end
columnData[2].startIndex = 1

– third column
columnData[3] = {}
for i=1,25 do
columnData[3][i] = i+2011
end
columnData[3].startIndex = yearIndex

local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=50,
columns=columnData
}
local widget = require “widget”
widget.setTheme (“theme_ios”)
– create table to hold all column data
local columnData = {}

– create first column
columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1

– second column (lots of rows)"
columnData[2] = { “00”,“01”,“02”,“03”,“04”,“05”,“06”,“07”,“08”,“09”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”,“26”,“27”,“28”,“29”,“30”,“31”,“32”,“33”,“34”,“35”,“36”,“37”,“38”,“39”,“40”,“41”,“42”,“43”,“44”,“45”,“46”,“47”,“48”,“49”,“50”,“51”,“52”,“53”,“54”,“55”,“56”,“57”,“58”,“59” }
columnData[2].alignment = “center”
for i= 1,59 do
– columnData[2][i] = i
end
columnData[2].startIndex = 1

– third column
columnData[3] = { “AM”, “PM” }
columnData[3].startIndex = 1

– create the actual picker widget with column data
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=200,
columns=columnData
}
local label = display.newText(“Tap here to schedule a text”, 0, 0, font, 18) ;
label:setReferencePoint(display.BottomCenterReferencePoint);
label:setTextColor(255, 255, 255) ;
label.x = display.contentWidth * 0.5;
label.y = display.contentHeight * .94;

–group:insert( background )

function label:tap(e)
native.showAlert(“Message”,“Scheduled to be sent!”,{“Ok”})
native.showPopup(“sms”,{

}) ;
end

label:addEventListener(“tap”, label);

system.vibrate()

–end

function time_to_notify(hora_in, minutos_in)
local utcTime = os.date( “!*t”, os.time() )
local timeTable = os.date("*t")
local hora_cl = timeTable.hour
local minuto_cl = timeTable.min

segundos_cl = (hora_cl*60*60)+(minuto_cl*60)
segundos_in = (hora_in*60*60)+(minutos_in*60)

if(segundos_cl>segundos_in)then
seg_reg = 86400 - segundos_cl + segundos_in
end

if(segundos_cl<segundos_in> seg_reg = segundos_in-segundos_cl
end

back = os.date( “!*t”, os.time() + seg_reg )
return back

end
[/code]
[import]uid: 69302 topic_id: 31252 reply_id: 125684[/import] </segundos_in>

Hi again, let me investigate this a bit further… specifically the widget and how it returns info that can be used elsewhere.

By the way, I see the “time_to_notify” function is written (partially) in Spanish or Portuguese. Where are you located? As a Corona ambassador, I’m curious about Corona’s international exposure and in which countries developers are using it. Simply curious though… you don’t need to elaborate if you don’t want to. :slight_smile:

Brent [import]uid: 9747 topic_id: 31252 reply_id: 125706[/import]

Hello Brent,
Do you mind explaining to me how I can get that scheduled notification event listener to listen to a widget? [import]uid: 69302 topic_id: 31252 reply_id: 125451[/import]

Hi again,
I don’t quite understand what you mean by “listen to a widget”. Can you explain in more detail what your ultimate goal is?

Brent
[import]uid: 9747 topic_id: 31252 reply_id: 125456[/import]

Ok so I am going to do my best explaining. users generate lets say a message and I have a widget with a date and time that allows users to choose a specific date and time. I want the message to be sent at the specific date and time they chose from the widget. I hope that makes sense?? [import]uid: 69302 topic_id: 31252 reply_id: 125459[/import]

Ha ha. Well unfortunately I am now in MA working on my masters from Harvard. But Portuguese is my first language so I wanted to incorporate in. But born in Cape Verde [import]uid: 69302 topic_id: 31252 reply_id: 125770[/import]

Hi again,
I checked into this a bit further. It looks like there’s a demo Widget project in the local Corona application directory (on your computer). It’s located here:

CoronaSDK > SampleCode > Interface > WidgetDemo

And it looks like you retrieve the info like this…

local pickerValues = picker:getValues()  
monthIndex = pickerValues[1].index  
dayIndex = pickerValues[2].index  
yearIndex = pickerValues[3].index  

In your project, that would probably go within your function “function label:tap(e)”. “picker” of course refers to the picker wheel, and the “getValues” call retrieves what the user selected. You’d then pass those values to your notification scheduler, the one written in Portuguese. :slight_smile:

Does this help? As I mentioned, I’m not an expert on the Widget library, but this is the basic concept behind retrieving info from a widget. Then you can use that info however you need.

Best of luck!
Brent
[import]uid: 9747 topic_id: 31252 reply_id: 125865[/import]

Ha ha I am so lost right now :slight_smile: [import]uid: 69302 topic_id: 31252 reply_id: 125867[/import]

I think it’s closer than you think. :slight_smile: I trimmed down your code to the following, which works at the basic level. Lines 44-47 pass the pickerWheel values to the notification scheduler. I can’t confirm that they’re the exact values you’ll need… very likely you’ll need to modify them a bit before sending them to the scheduler… but this should clarify the basic process.

If you’re still lost, let me know where exactly you’re lost (what line, what function). And I suggest you use the humble “print()” statement to really nail this down… print EVERYTHING you can (you can always comment-out them later)… print variables after you declare them and before you pass them… and watch the Terminal for what’s going on. Many developers ignore the print() statement like it’s a worthless newbie command, but if I had $1 for every time the print() statement has saved my a** or solved a mystifying coding problem, I’d be filthy rich. :slight_smile:

Brent

[code]
local widget = require “widget”
widget.setTheme (“theme_ios”)

– create table to hold all column data
local columnData = {}

– create first column
columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1

– second column (lots of rows)"
columnData[2] = { “00”,“01”,“02”,“03”,“04”,“05”,“06”,“07”,“08”,“09”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”,“26”,“27”,“28”,“29”,“30”,“31”,“32”,“33”,“34”,“35”,“36”,“37”,“38”,“39”,“40”,“41”,“42”,“43”,“44”,“45”,“46”,“47”,“48”,“49”,“50”,“51”,“52”,“53”,“54”,“55”,“56”,“57”,“58”,“59” }
columnData[2].alignment = “center”
for i= 1,59 do
– columnData[2][i] = i
end
columnData[2].startIndex = 1

– third column
columnData[3] = { “AM”, “PM” }
columnData[3].startIndex = 1

– create the actual picker widget with column data
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=200,
columns=columnData
}
local label = display.newText(“Tap here to schedule a text”, 0, 0, font, 18) ;
label:setReferencePoint(display.BottomCenterReferencePoint);
label:setTextColor(255, 255, 255) ;
label.x = display.contentWidth * 0.5;
label.y = display.contentHeight * .94;

function label:tap(e)
–native.showAlert(“Message”,“Scheduled to be sent!”,{“Ok”})
–native.showPopup(“sms”,{}) ;
local pickerValues = picker:getValues()
print(pickerValues[1].index)
print((pickerValues[2].index)-1)
time_to_notify( pickerValues[1].index, (pickerValues[2].index)-1 )
end
label:addEventListener(“tap”, label);
–system.vibrate()

function time_to_notify(hora_in, minutos_in)
local utcTime = os.date( “!*t”, os.time() )
local timeTable = os.date("*t")
local hora_cl = timeTable.hour
local minuto_cl = timeTable.min

segundos_cl = (hora_cl*60*60)+(minuto_cl*60)
segundos_in = (hora_in*60*60)+(minutos_in*60)

if(segundos_cl>segundos_in)then
seg_reg = 86400 - segundos_cl + segundos_in
end

if(segundos_cl<segundos_in> seg_reg = segundos_in-segundos_cl
end

back = os.date( “!*t”, os.time() + seg_reg )
return back

end
[/code] [import]uid: 9747 topic_id: 31252 reply_id: 125888[/import] </segundos_in>