2014-03-05 141 views
1

你好,我設置了聲音的名稱給UILocal通知,但是它沒有播放它的正確,但是當通知被觸發時聲音不響,默認聲音也沒有播放。 曲甲是.waw這是由蘋果支持..聲音不在UILocal通知中播放

的源代碼:

[[UIApplication sharedApplication] cancelAllLocalNotifications]; 
UILocalNotification *notification=[[UILocalNotification alloc]init]; 
notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:100]; 
[email protected]"Time to wake up"; 
notification.alertAction = @"Snooze"; 
[email protected]"Guitar.wav"; 
//notification.soundName = UILocalNotificationDefaultSoundName; 
notification.applicationIconBadgeNumber = 1; 
[[UIApplication sharedApplication] scheduleLocalNotification:notification]; 

回答

0

我發現我的問題的解決方案是在iPhone的通知中心我的應用程序聲音關閉,所以我只是打開它和它的工作。

0

試試這個雙向的,並得到這是你嗎?

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

    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5]; 

    localNotification.timeZone = [NSTimeZone defaultTimeZone]; 
    localNotification.alertBody = @"You have long time to care your......"; 
    localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber]+1; 
    localNotification.soundName = UILocalNotificationDefaultSoundName; 
    localNotification.repeatInterval = kCFCalendarUnitMinute; 
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
    [localNotification release]; 
    localNotification = nil; 

//////////// OR ///////////////

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

    // Set the notification time. 
    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10]; 

    // You can specify the alarm sound here. 
    localNotification.soundName = UILocalNotificationDefaultSoundName; 
    //OR 
    localNotification.soundName = @"sound.caf"; 

    // Set the alertbody of the notification here. 
    localNotification.alertBody = @"Test Alert"; 

    // Create the buttons on the notification alertview. 
    localNotification.alertAction = @"View"; 

    // You can also specify custom dictionary to store informations 
    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"alarm#2" forKey:@"notifiKey"]; 
    localNotification.userInfo = infoDict; 

    //Repeat the notification. 
    localNotification.repeatInterval = NSDayCalendarUnit; 

// Schedule the notification 
[[UIApplication sharedApplication]scheduleLocalNotification:localNotification]; 
0

嘗試將您的聲音轉換成CAF格式int終端命令:

afconvert -f caff -d [email protected] -c 1 in.wav out.caf 

並確保聲音小於30秒。