前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >iOS app处于后台/被杀死的状态仍可进行语言播报(iOS12.1以上在后台或者被杀死无法语音播报的解决方案)

iOS app处于后台/被杀死的状态仍可进行语言播报(iOS12.1以上在后台或者被杀死无法语音播报的解决方案)

作者头像
公众号iOS逆向
发布2021-03-24 16:06:19
9320
发布2021-03-24 16:06:19
举报
文章被收录于专栏:iOS逆向与安全iOS逆向与安全

前言

  • CSDN资源下载源码:https://download.csdn.net/download/u011018979/14026303

1、原文:https://kunnan.blog.csdn.net/article/details/103702284 2、本文提供iOS12.1系统以上在后台或者被杀死无法语音播报的解决方案:通过NotificationServiceExtension实现

  • 想要消息推送的消息在Service Extension中被处理,需要aps 内容中包含mutable-content : 1. (以极光平台推送为例,测试的时候,需要在高级设置开启mutable-content)
代码语言:javascript
复制
    aps =     {
alert =         {
    body = 11;
    subtitle = 111;
    title = "111223411.34";
};
badge = 1;
"mutable-content" = 1;
sound = default;
};
hasHandled = 1; //标记已经在Extension中被处理,防止重复的语言播报或者打印交易小票等冗余动作。
}

  • 正确的消息推送格式
代码语言:javascript
复制
{"aps":{"alert":"This is some fancy message.","badge":6,"sound": "default","content-available":true,"mutable-content":true}}

I 、开发步骤

1、创建NotificationServiceExtension

  • 1.1选择新建Notification Service Extension

在这里插入图片描述

  • 1.2 创建NotificationService.m继承UNNotificationServiceExtension ,并实现方法- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler

NotificationService.m

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-03-19,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 iOS逆向 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • I 、开发步骤
    • 1、创建NotificationServiceExtension
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档