当你没有权利文件时,你会做什么?
发布于 2021-02-05 05:07:37
有几个来源可以帮助您为您的iOS应用程序实现关键警报。我发现有两个非常有用的:
https://www.tapcode.co/2018/10/17/how-to-implement-critical-alerts-in-ios-12/
这两种方法都描述了请求苹果批准所需的内容,以及如何更新您的项目以包括关键警报通知--只有一个例外。文章解释了如何更新应享待遇文件以添加关键警报键。但是,当你的应用程序目前没有权利文件时,你会做什么?经过一番研究,我得出了以下步骤,可以作为解决这一困境的指南。当您进入文章中处理更新应享权利文件的部分时,请按以下方式进行:
任务完成!
特里·查瓦松
发布于 2021-07-25 21:23:15
关于如何实现IOS关键警报的指南2021年7月
第一步
请求批准后您需要做什么?









如何在XCODE中选择您的配置文件


如何添加应享权利文件





我们需要添加到代码中的内容
请求授权
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .badge, .sound, .criticalAlert]) { (granted, error) in}用于本地通知的
将您的UNMutableNotificationContent声音更改为下一个:
let notificationContent = UNMutableNotificationContent()
notificationContent.sound = UNNotificationSound.defaultCritical如果要使用自定义声音,则需要将代码替换为以下代码:
let notificationContent = UNMutableNotificationContent()
notificationContent.sound = UNNotificationSound.criticalSoundNamed(UNNotificationSoundName(rawValue:"YourCustomSound.mp3"))推送通知的(来自Tapcode教程)
{
"aps":{
"alert": "This is a Critical Alert!",
"badge": 1,
"sound": {
"critical": 1,
"name": "your_custom_sound.aiff",
"volume": 1.0
}
}
}https://stackoverflow.com/questions/66057840
复制相似问题