Ios 本地通知中未播放声音
您好,我将声音的名称设置为UILocal notification,但它的播放不正确,但在触发通知时声音不会响起,并且默认声音也不会播放。 歌曲格式为.waw,由apple支持 源代码:Ios 本地通知中未播放声音,ios,iphone,Ios,Iphone,您好,我将声音的名称设置为UILocal notification,但它的播放不正确,但在触发通知时声音不会响起,并且默认声音也不会播放。 歌曲格式为.waw,由apple支持 源代码: [[UIApplication sharedApplication] cancelAllLocalNotifications]; UILocalNotification *notification=[[UILocalNotification alloc]init]; notification.fireD
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *notification=[[UILocalNotification alloc]init];
notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:100];
notification.alertBody=@"Time to wake up";
notification.alertAction = @"Snooze";
notification.soundName=@"Guitar.wav";
//notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
试试这两种方法,你会得到哪一种
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;
////////////或///////////////
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];
尝试使用以下命令将声音转换为caf格式的int terminal:
afconvert -f caff -d LEI16@44100 -c 1 in.wav out.caf
确保声音低于30秒 我在iphone的通知中心找到了解决问题的方法,我的应用程序声音关闭了,所以我只需打开它,它就可以工作了