0

I'm practicing to develop Alarm app like Alarm on IOS 7. Alarm time up on IOS7 However, I stuck at local notification at locked screen, it just like this. My notification Some code I did:

In my AppDelegate.m

My code

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

    // Handle launching from a notification
    UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

....
..in my ViewController.m..

[self scheduleLocalNotificationWithDate:correctDate];
....
(void)scheduleLocalNotificationWithDate:(NSDate *)fireDate {

    UILocalNotification *localNotification = [[UILocalNotification alloc] init];

    localNotification.fireDate = fireDate;
    localNotification.alertBody = [NSString stringWithFormat:@"Alert Fired at %@", fireDate];
    localNotification.soundName = UILocalNotificationDefaultSoundName;

    localNotification.applicationIconBadgeNumber = numberReminder;
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

Who can help to do that?

Thanks

Raviteja
  • 3,399
  • 23
  • 42
  • 69
AbleTran
  • 1
  • 1

2 Answers2

0

Third-party apps don’t get to appear on the lock screen the way the system alarm-clock app does—your app can only produce ordinary notifications. If you’d like an API added to get the full-screen alert style, you might try filing an enhancement request.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
-1
 if([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}

UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

if(notification) {       
    application.applicationIconBadgeNumber = 0;
}

And in View Controller.m call this function

- (void) Notify {
NSDate *fireDate = [[NSDate alloc]init];
fireDate = self.datePicker.date;    

NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *dateComp = [cal components:(NSCalendarUnitHour | NSCalendarUnitMinute| NSCalendarUnitSecond) fromDate:fireDate];    

NSDate *dd = [cal dateByAddingComponents:dateComp toDate:fireDate options:0];    

UILocalNotification *notification = [[UILocalNotification alloc]init];
[notification setFireDate:dd]; 
[[UIApplication sharedApplication] scheduleLocalNotification:notification];

}

ck1924
  • 9
  • 3
  • This… just tries to do what the OP’s code already does, only it doesn’t even work since you’re not calling `+scheduleLocalNotification:` with the notification after creating it. – Noah Witherspoon Jan 28 '16 at 16:58
  • Sorry about the incomplete code, Have edited now. Hope this works. – ck1924 Jan 28 '16 at 17:02