Push notifications

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Push notifications

Post by Simon » Wed Aug 21, 2013 8:04 pm

Actually all you need is event day time.
"convert "9/1/13" to seconds"
Doesn't matter when you start.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Push notifications

Post by Opaquer » Wed Aug 21, 2013 11:41 pm

That makes this so much easier! Here I was making it so that it would get the date of the event, then split it up by the /, then take the day and subtract it from the current day, and same for the month and year, and repeat :P. Glad to know that there's a much easier way :D!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Push notifications

Post by Simon » Thu Aug 22, 2013 12:03 am

You can do a test for me.
Since I don't think you can cancel a notification once it's set on the device, can you add another notification at the same seconds with a payload of "This has been canceled"?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Push notifications

Post by Opaquer » Thu Aug 22, 2013 12:48 am

What exactly is the payload and badge :S? I didn't quite get it when I was reading it :S. Also, there's the mobileCancelLocalNotification command, which seems like if you enter in the right syntax, it will cancel said notification. The command is "mobileCancelLocalNotification notification" Would it be the badge number, or the payload, or what :S?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Push notifications

Post by Simon » Thu Aug 22, 2013 1:27 am

Ok wicked there is a cancel. Good news.
For the different alert... just fill them all and see where they end up.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Push notifications

Post by Opaquer » Thu Aug 22, 2013 1:36 am

Which different alerts is that?

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Push notifications

Post by Opaquer » Thu Aug 22, 2013 1:50 am

Hmm. I'm having a bit of trouble with the convert to seconds. I've got:

Code: Select all

   convert date() to seconds 
   put it into datesec
   convert time() to seconds
   put it into timesec
   convert word 1 of eventtime to seconds
   put it into eventsec
   answer eventsec
   if word 2 of eventtime = "PM" then
      put eventsec+43200 into eventsec
   end if
Which all mostly works. But for some reason, when I test it out with the time 10:10PM, it doesn't quite convert the time properly. Instead of using the time of the event, it's using the current time :(. It's a problem with how I've used the it part of the code, isn't it :(? Also, I can finally use the code tags :D!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Push notifications

Post by Simon » Thu Aug 22, 2013 2:08 am

Look up dateItems, in your app you don't have to use it but it's format can be converted to seconds
e.g.
convert "2013,8,21,17,56,0,4" to seconds
the items above are described in the dateItems.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Push notifications

Post by Opaquer » Thu Aug 22, 2013 4:50 am

Hmm. I think for now I like the method I'm using. I just can't figure out why it's not working and using the time instead of the eventsec :(

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Push notifications

Post by jacque » Thu Aug 22, 2013 6:33 pm

It's hard to say why it's failing until we know what's in eventtime. What's the value?

Simon's right though, dateitems would do a better job. It handles all sorts of things automatically without any calculations.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Push notifications

Post by Opaquer » Thu Aug 22, 2013 11:51 pm

Sorry, I realised last night that I forgot to include eventtime! I figured it out sort of though? Instead of using:

Code: Select all

   convert word 1 of eventtime to seconds
   put it into eventsec
I just eneded to use:

Code: Select all

   put word 1 of eventtime into eventsec
   convert eventsec to seconds
Not entirely sure why it works, but it seems to work now :D!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Push notifications

Post by jacque » Fri Aug 23, 2013 7:23 pm

I've had inconsistent results when I don't put the time/date into a variable before using the convert command. I think you just hit one of those. I always use this form:

Code: Select all

put the date into tDate
convert tDate to seconds
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Push notifications

Post by Opaquer » Fri Aug 23, 2013 11:51 pm

That could be it. Either way, I'm rather glad it works :P. It was quite annoying when it wasn't working :P

Post Reply