我正在iPad模拟器上测试我的应用。但是有一些提示音播放的问题。
通知声音将在应用程序在前台运行时播放,而不是在后台运行。它显示一个横幅类型的通知,没有任何声音。我想知道iPad模拟器中的通知设置是否决定了这种情况。iPhone的设置应用程序有"通知"菜单,我们可以设置通知类型——无通知、横幅通知、提醒通知和声音通知等等。我无法找出iPad设备设置应用程序,因为我没有iPad:(
iPhone模拟器和iPhone设备工作正常。但不是iPad模拟器。
-(void) registerNoti {
localNotif.fireDate = noti.date;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
//Payload
localNotif.alertBody = [NSString stringWithFormat:@"%@",cell.textLabel.text];
localNotif.alertAction = @"Run App";
localNotif.soundName = @"sound.mp3";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
有没有办法解决iPad模拟器通知声音问题?或者我可以忽略这个问题,这样就可以了吗?
尝试定义mp3文件的完整路径:
localNotif.soundName = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"mp3"];
它可能对你有帮助。
如果你没有iPad(或者你的朋友有iPad可以帮你测试),那就不要在iPad上发布这款应用。永远不要依赖模拟器。必须最终在设备上进行测试。你的问题就是一个例子:你现在是在凭猜测编程,这是在自找麻烦。你不知道你的应用真正做了什么(因为"真正"只能意味着"在设备上")。