推送实现 应用未启动情况下的自定义声音播放

1、将推送的权限证书等配置好

2、创建 UNNotificationServiceExtension (iOS 10及以后)

3、在 

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler 方法中拿到 self.content = [request.content mutableCopy];
并将
self.content.sound = [UNNotificationSound soundNamed:[NSString stringWithFormat:@"%@.mp3",soundFileUrl]]; 设置成自己想要播放的声音

 

posted @ 2020-05-25 09:34  心里住着鬼  阅读(453)  评论(0编辑  收藏  举报