惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Exploit Database - CXSecurity.com
A
Arctic Wolf
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cisco Blogs
AWS News Blog
AWS News Blog
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
美团技术团队
T
Threatpost
S
Schneier on Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cyber Attacks, Cyber Crime and Cyber Security
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
Blog — PlanetScale
Blog — PlanetScale
C
Cybersecurity and Infrastructure Security Agency CISA
F
Full Disclosure
博客园_首页
N
Netflix TechBlog - Medium
Security Latest
Security Latest
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Register - Security
The Register - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Recent Announcements
Recent Announcements
博客园 - Franky
P
Palo Alto Networks Blog
Project Zero
Project Zero
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Cisco Talos Blog
Cisco Talos Blog
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 【当耐特】
GbyAI
GbyAI

博客园 - 朝阳向日葵

AI辅助工作实践报告 Claude Code介绍 AI使用相关 蓝牙 报错处理 iOS IPA体积优化 关于GPT工具的操作说明 React Native之React基础 React Native之JSX语法 使用TestFlight安装ios SwichBot的测试版本 React Navite环境搭建 iOS 防止charles抓包 iOS Charles抓包 转正答辩 iOS设备和模块解耦-方案对比 iOS开发 性能优化 iOS开发 调试技巧 设计模式 项目架构 iOS 常用第三方库及原理
iOS开发 重要通知(critical-alerts)
朝阳向日葵 · 2023-11-16 · via 博客园 - 朝阳向日葵

重要警报(critical-alerts)是 iOS 12 和 watchOS 5.0 中的一种新型选择加入通知,允许绕过“请勿打扰”和静音开关。他的本意是出现紧急情况,需要用户立即关注的关键事件。

一、适用程序

苹果不允许通过重要通知来推送营销信息,因此,此类通知仅限于医疗或健康相关应用程序、公共安全或特殊安全应用程序。所以,重要警报需要苹果公司授予的特殊授权。

需要填写的内容:

1.app类型 2.描述我们的app 3.发送紧急通知的消息类型 4.紧急通知的频率 5.解释为什么需要用到紧急通知及功能设计过程

我们需要解释应用正在做什么以及计划如何向我们发送重要警报。Apple 希望您列出一个令人信服的理由,说明为什么我们的应用程序可能需要用户立即关注。

最后就是等待申请结果的邮件。

二、配置文件

登陆苹果开发者账号,选择要启用关键警报的应用程序的标识符。勾选“重要警报”框。然后单击“保存”按钮。

导航到Profiles,然后单击加号按钮注册新的配置文件。

选择“iOS 应用程序开发”选项,然后单击“继续”按钮。

选择您的应用程序 ID,然后单击“继续”按钮。

选择所有证书并单击“继续”按钮。

选择您的设备并单击“继续”按钮。

输入您的配置文件的名称,然后单击“生成”按钮。

单击“下载”按钮。然后双击以下文件来安装您的配置文件,发布证书也是相同流程。

Xcode 配置

选择您在前面的步骤中下载并安装的配置文件。

查看权限

在设置UNUserNotificationCenter中增加criticalAlert

func requestAuthorization(completion: ((Bool, Error?) -> Void)?) { let options: UNAuthorizationOptions if #available(iOS 12.0, *) { options = [.alert, .badge, .sound, .criticalAlert] } else { options = [.alert, .badge, .sound] } UNUserNotificationCenter.current().requestAuthorization(options: options) { (granted, error) incompletion?(granted, error) } }

然后在app.entitlements中增加keycom.apple.developer.usernotifications.critical-alerts类型为boolean 并将值设为1

Critical alerts APNS 格式

最后,需要在从服务器发送推送通知时修改 APS,可以加入声音键对象。

{ "aps":{ "alert": "This is a Critical Alert!", "badge": 1, "sound": { "critical": 1, "name": "your_custom_sound.aiff", "volume": 1.0 } } }

添加自定义声音文件(.aiff 格式)并指定设备音量(值 0.0 到 1.0),其中 1.0 表示全音量。

如何测试紧急通知

工具下载:

工具界面:

需要的参数配置:

  1. .p8

  1. key ID

3.team id:

4:bundle id :

5.device token:

代码里获取 ===device token:===d94d073a2ba5aae294920dd0d7680c2fb06fd4146bc9bee3a889f9d5acd86899

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        print("===device token:===\(deviceToken.hexString)")
        // 记录/获取推送token,发生改变则将token上传
        if UserDefaults.standard.object(forKey: "lastSnsToken") == nil {
            WoUser.currentUser.needUpload = true
            UserDefaults.standard.set(deviceToken.hexString, forKey: "lastSnsToken")
        } else {
            let lastSnsToken: String = UserDefaults.standard.object(forKey: "lastSnsToken") as! String
            if lastSnsToken != deviceToken.hexString {
                WoUser.currentUser.needUpload = true
                UserDefaults.standard.set(deviceToken.hexString, forKey: "lastSnsToken")
            } else {
                WoUser.currentUser.getUploadUserInfoTag()
            }
        }
//        Replies.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
        
    }

 发送成功结果:

 手机端会听到尖锐报警音,和如下图效果:

posted @ 2023-11-16 15:08  朝阳向日葵  阅读(1025)  评论()    收藏  举报