2014-03-05 107 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秒。