Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-06-2010, 01:27 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 9
Roon is on a distinguished road
Default cancelLocalNotification fails

Updating GameTimers app for iOS 4, we're adding UILocalNotification for each of up to 30 activated countdown timers. Two locals are set, one when the timer reaches its target time, and then a second when the timer approaches the "grace period" (in cafe world lingo, it's just before the food spoils).

Everything is working as expected, and when a timer is canceled by the user, I step through all existing timer notifications, canceling those which have the same ID as the timer canceled by the user (calling cancelLocalNotification:timerID). Going back to confirm, I log that only the appropriate timers' local notifications are left (example below).

However, the "expiration" timer notification of the canceled item, one which hasn't gone off yet following a grace period, somehow continues to triggers.

Any ideas?

Code:
2010-07-06 13:17:16.538 GameTimers[1453:307] Timer ID: 24   2010-07-06 15:17:07 -0400   The Timer 'T1' Is Ready!
2010-07-06 13:17:16.562 GameTimers[1453:307] Timer ID: 24   2010-07-06 17:07:07 -0400   The Timer 'T1' Will Expire Soon!
Roon is offline   Reply With Quote
Old 07-06-2010, 02:34 PM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

I didn't quite understand your issue. My pending notifications were all properly canceled with the approach you mentioned on my thread. Are you certain you have set the userInfo dictionary to both UILocalNotification objects when you scheduled them ?
nobre84 is offline   Reply With Quote
Old 07-06-2010, 02:43 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 9
Roon is on a distinguished road
Default

That's the problem... they've all been canceled as per the code, but somehow the OS is hanging onto one that has been canceled but not activated. I found this with firedates >= 2 hours. Really annoying when there is a 1 or 2 day timer going off a day after its been canceled.
Roon is offline   Reply With Quote
Old 07-06-2010, 03:17 PM   #4 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

I see. I have default timers 24h before, 1h before and on the event date itself
Both of the former values did not fire after being canceled, haven't tried with longer periods.
nobre84 is offline   Reply With Quote
Old 07-06-2010, 07:32 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 9
Roon is on a distinguished road
Default

Quote:
Originally Posted by nobre84 View Post
I see. I have default timers 24h before, 1h before and on the event date itself
Both of the former values did not fire after being canceled, haven't tried with longer periods.
I just ran across an anomaly out of UILocalNotification on Apple's part. During stress testing this problem, suddenly the OS is creating a timerID of zero, when the actual timerID is 27. I'm not sure if this is the bug I'm hunting for in this thread, but the notification would never be cleared since I never have an ID of zero! I'll have to fix that, and send a note over to Apple.

Code:
2010-07-06 20:22:13.975 GameTimers[1755:307] Delegate did finish launching
2010-07-06 20:22:14.004 GameTimers[1755:307] Timer ID: 0   2010-07-06 17:47:09 -0400   The Timer 'T4' Is Ready!
2010-07-06 20:22:14.032 GameTimers[1755:307] Timer ID: 27   2010-07-06 20:10:27 -0400   The Timer 'T4' Is Ready!
Roon is offline   Reply With Quote
Old 07-07-2010, 07:30 AM   #6 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 9
Roon is on a distinguished road
Default

Found the culprit, I failed to do an alloc on my userInfo NSMutableDictionary object, so the timerID values were getting flushed over long timer runs.
Roon is offline   Reply With Quote
Old 07-07-2010, 08:36 AM   #7 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

Glad you found the issue!
nobre84 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 331
8 members and 323 guests
anothermine, Chickenrig, firecall, givensur, iNet, michaelhansen, PixelInteractive, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:29 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0