Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Apparently we cannot change the alertBody on demand every time the repeatInterval is getting called. So wrong....</p> <p>Anyway here is the code I using now:</p> <pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application { UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.alertBody = @"Hey, I've got a tip for you..."; notification.fireDate = [[NSDate date] dateByAddingTimeInterval:60*60*24]; notification.repeatInterval = NSDayCalendarUnit; //NSMinuteCalendarUnit | NSDayCalendarUnit [[UIApplication sharedApplication] scheduleLocalNotification:notification]; application.applicationIconBadgeNumber = application.applicationIconBadgeNumber + 1; } - (void)applicationDidBecomeActive:(UIApplication *)application { [[UIApplication sharedApplication] cancelAllLocalNotifications]; if (application.applicationIconBadgeNumber &gt; 0) { //check if user has been notified... even if user cleared the notification, an alert will still show with the Tip of The Day... NSString *path = [[NSBundle mainBundle] pathForResource: @"myTipOfTheDay" ofType:@"plist"]; NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:path]; NSMutableArray *plistArray = plistDict[@"randTip"]; int randV = arc4random() % plistArray.count; //random selection of string UIAlertView *tipOfTheDaAlert = [[UIAlertView alloc] initWithTitle:@"Did you know that..." message:plistArray[tipOfDay] delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [tipOfTheDaAlert show]; application.applicationIconBadgeNumber = 0; //reset the icon badge to zero } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload