http://stackoverflow.com/questions/4188848/uilocalnotification-custom-sound
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *push = [[UILocalNotification alloc] init];
push.fireDate = [NSDate dateWithTimeInterval:1 sinceDate:[NSDate date]];
push.alertBody = [NSString stringWithFormat:@"%@",bl.text];
//push.soundName = UILocalNotificationDefaultSoundName;//能够播放系统默认提示音;
//push.soundName = [[NSBundle mainBundle] pathForResource:@"pushSound" ofType:@"wav"];//用该方式获取的文件无法正常播放
push.soundName = @"push.wav";//文件保存在source目录下(放到其他工程目录下也是可行的)
NSDictionary * dic = @{@"major":bl.major,@"minor":bl.minor,@"x":bl.x,@"y":bl.y};
push.userInfo = dic;
[[UIApplication sharedApplication] scheduleLocalNotification:push];
//push.soundName = [[NSBundle mainBundle] pathForResource:@"pushSound" ofType:@"wav"];//用该方式获取的文件无法正常播放 push.soundName = @"pushSound.wav";//文件保存在source目录下(放到其他工程目录下也是可行的)
1.注意:音频文件时长需要小于30秒的。。
2.扩展思考下:能否使用Doucument目录下自己录制生成的音频文件来作为推送提示音
网友评论