실시간으로 알람을 설정하거나 해제하고 단일 톤 오디오를 재생할 수있는 간단한 알람 알림 앱을 만들었습니다. 하지만 클래스 VOID
으로 시작해야하는 사운드를 재생해야합니다. 나는 radiosound
재생을 시작하기 위해 알람을 설정할 수있는 방법iOS 알람 시계
- (void)playPause {
RADAppDelegate *appDelegate = (RADAppDelegate *)[[UIApplication sharedApplication] delegate];
if (appDelegate.radiosound == 0){
[appDelegate.radiosound play];
} else {
[appDelegate.radiosound pause];
}
}
:
- (void)viewDidLoad {
[super viewDidLoad];
dateTimerPicker.date = [NSDate date];
}
- (void)presentMessage:(NSString *)message {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hello!"
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
}
- (void)scheduleLocalNotificationWithDate:(NSDate *)fireDate {
UILocalNotification *notification = [[UILocalNotification alloc]init];
notification.fireDate = fireDate;
notification.alertBody = @"Time to wake up!!";
notification.soundName = @"PhoneOld.mp3";
[self playPause];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
- (IBAction)alarmSetOn:(id)sender{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *dateTimeString = [dateFormatter stringFromDate:dateTimerPicker.date];
NSLog(@"Alarm Set: %@", dateTimeString);
[self scheduleLocalNotificationWithDate:dateTimerPicker.date];
[self presentMessage:@"Alarm ON!"];
}
- (IBAction)alarmSetOff:(id)sender {
NSLog(@"Alarm Off");
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[self presentMessage:@"Alarm OFF!"];
}
이 내 VOID입니다 :
얻을 및 경보 알림을 시작하려면 : 아래
코드입니다 0과 같은 0 인 경우 :notification.soundName = [self playPause];
그러나 이것은 NSString
이라는 것을 알고 있습니다.
IMO는 예약 알림을 취소하고 'notification.soundName = radioSound;'(으)로 새 알림 일정을 변경합니다. – Bala
무엇이 질문입니까? 알림에서 스트리밍 사운드를 재생하는 방법 (할 수 없음), 앱에 알림 호출을하는 방법 (사용자가 알림을 허용하지 않는 한 알림을 보내지 않음), 알림에서 소리를 재생하는 방법 Aniket은 아래 답변), 또는 다른 뭔가? – AndrewS