2011-08-01 6 views
7

알람 앱을 만들려고 시도하지만 iTunes에서 노래를 로컬 알림 소리로 설정하는 방법을 모르겠습니다.iTunes에서 노래의 사운드 로컬 알림을 설정하는 방법은 무엇입니까?

지금이 같은 지역 알림 모습에 대해

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.section == 0) { 
     MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic]; 

     picker.delegate = self; 
     picker.allowsPickingMultipleItems = NO; 
     picker.prompt = NSLocalizedString (@"Select any song from the list", @"Prompt to user to choose some songs to play"); 

     //[self presentModalViewController: picker animated: YES]; 
     [self.navigationController pushViewController:picker animated:YES]; 

     NSLog(@"gsudifghukdsf"); 
     [picker release]; 

    } 
} 

- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection 
{ 
    [self.navigationController popToRootViewControllerAnimated:YES]; 
    //[self dismissModalViewControllerAnimated: YES]; 
    NSLog(@"%@",mediaItemCollection); 

    UILocalNotification *local = [[UILocalNotification alloc] init]; 
    //selectedSongCollection=mediaItemCollection; 

} 

- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker 
{  
    [self.navigationController popToRootViewControllerAnimated:YES]; 
    //[self dismissModalViewControllerAnimated: YES]; 
} 

아이튠즈

뭔가를 호출하는이 코드를 사용

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 
    if (localNotif == nil) 
    { //NSLog(@"Get in if localNotif"); 
     return; 
    } 

    localNotif.fireDate = DateAlarm; 

    localNotif.timeZone = [NSTimeZone defaultTimeZone]; 

    // Notification details 
    localNotif.alertBody = [NSString stringWithFormat:@"%@",DateAlarm]; 
    // Set the action button 
    localNotif.alertAction = @"Oh Shit"; 



    localNotif.soundName = UILocalNotificationDefaultSoundName; 

그래서 지역의 소리에 노래를 설정하는 방법 나를 인도 해주십시오?

+0

안내해주세요. 아니면 할 수 없어 ?? – crazyoxygen

+0

이 URL로 확인하십시오. http://www.techotopia.com/index.php/Scheduling_iOS_4_iPhone_Local_Notifications#Adding_a_Sound_File_to_the_Project –

답변

9

메인 번들의 일부인 소리 만 사용할 수 있습니다. 즉, 앱 스토어에 제출할 때 앱 빌드에 있다는 소리입니다.

예, 앱에 사운드를 녹음하고 사운드를 다운로드 할 수는 있지만 앱의 번들에 포함되어 있지 않기 때문에 생성되거나 저장된 파일은 사용할 수 없습니다. 앱이 번들 외부에서 외부 사운드에 액세스하여 맞춤 사운드를 사용하는 경우 개인용 API를 사용하여 맞춤 사운드를 사용합니다. 저를 믿으십시오, 나는 나가 생각할 수있는 각 선택권을 시도했다.

+0

이 정확한 작업을 수행하는 앱을 보았습니다. 예 : [Rise] (https://itunes.apple.com/us/app/rise-alarm-clock/id577221529) 어떻게 생각하나요? 그들이 소리 처리를하는 것처럼 보이지만 확실하지는 않습니다. – r3dsm0k3

+0

그들이 어떻게하는지 잘 모르겠습니다. 현재 [UILocalNotification 클래스 참조] (http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html) 및 [로컬 및 푸시 알림 프로그래밍 가이드] (http : /developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html # // apple_ref/doc/uid/TP40008194-CH103) 둘 다 여전히 Main Bundle의 사운드로만 할 수 있다고 말합니다. 따라서 Main Bundle에서 사운드를 벼락치기위한 방법을 찾지 못했다면 전혀 알 수 없습니다. :( – thephatp

2

@thephatp에서 언급 한 것처럼 알림 (로컬 또는 원격)은 앱 번들에있는 소리 재생 만 트리거 할 수 있습니다. 이 문제를 둘러 볼 방법이 없습니다.

@ r3dsm0k3은 앱 번들에없는 소리를 Rise과 같은 앱에서 어떻게 재생하는지 그의 설명에서 묻습니다. 앱의 지원 배경 작업 배경 실행의 일부 유형의

지원을 사용하는 응용 프로그램에 의해 미리 선언해야 선언

: If I had to guess, I would say that Rise registers itself as an app requiring the audio background mode. 앱은 Info.plist 파일을 사용하여 서비스에 대한 지원을 선언합니다. 다음 문자열 중 하나 이상을 포함하는 배열에 당신의 Info.plist 파일에 UIBackgroundModes 키를 추가하고 해당 값을 설정 :

오디오 앱이 배경에있는 동안 사용자에게 가청 내용을한다. (이 내용은 스트리밍 오디오 또는 비디오 콘텐츠 에어 플레이를 사용하여 포함되어 있습니다.)

이 효과적으로 그 상승이 모든 시간을 실행 유지하도록 허용을 의미합니다. 그것은 사용자를 대신하여 오디오를 재생하므로 그렇게 할 수 있습니다. 그것이 오디오를 재생하지 못한다면 100 %의 시간은 애플에게는 문제가되지 않는다.

상승은 UILocalNotifications를 사용하거나 사용하지 않을 수 있습니다. 대부분의 경우 응용 프로그램이 언로드 된 경우 백업으로 만 사용하고 대신 다른 타이머 메커니즘을 사용하여 깨우기 경보 시퀀스를 트리거합니다.

관련 문제