알람 시계 iOS 앱을 쓰고 있습니다. UILocalNotification을 사용하여 처음입니다. 데이트 피커에서 데이트 할거야. 필자의 함수가 적절한 날짜를 지난 것인지 확인하기 위해 날짜 형식을 지정했습니다. 나는 UILocalNotification을 위해 필요한 모든 속성들을 검사했고 그것들은 모두 가지고 있었고 나의 통지는 여전히 실행되지 않을 것입니다. 왜 어떤 아이디어? 도와 주셔서 감사합니다.UILocal 알림이 실행되지 않습니다
#import "BIDAlarmViewController.h"
@interface BIDAlarmViewController()
@end
@implementation BIDAlarmViewController
@synthesize datePicker;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib
}
- (void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)setReminderUsingDateFromDatePicker: (id)sender{
[self scheduleNotificationForDate: datePicker.date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd 'at' HH:mm"];
NSString *formattedDateString = [dateFormatter stringFromDate:datePicker.date];
NSLog(@"Button Pressed.. date: %@", formattedDateString);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alarm activated"
message:@"Alarm has been set"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
-(void) scheduleNotificationForDate: (NSDate*)date {
UILocalNotification *alarm = [[UILocalNotification alloc] init];
if (alarm) {
alarm.fireDate = date;
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.repeatInterval = 0;
alarm.soundName = @"alarmsound.caf";
alarm.alertBody = @"Test message...";
[[UIApplication sharedApplication] scheduleLocalNotification:alarm];
}
}
@end
응용 프로그램 대리인에서 didReceiveLocalNotification 메서드를 구현 했습니까? – powerj1984
아니요, 아닙니다. 나는 그 위에 닦았다고 생각한다. 감사. – user1681673
그냥 호기심에서 벗어났습니다.받을 방법이 없다면 어떻게 알림을 받으려고 했습니까? –