本地推送 UILocalNotification 的 soundName 设置没有效果

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目录下自己录制生成的音频文件来作为推送提示音

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容