更改代码中的推送通知声音:iOS
我想在不从后端更改有效载荷的情况下更改推送通知的一些参数。
因此,该应用会收到推送通知:
{
"Simulator Target Bundle": "com.test.iphone.driver.test",
"aps":{
"alert":"This is Alert.",
"sound":"default"
}
}
但是在执行通知之前,我需要将代码中的声音更改为“ custom.mp3”。 应该在这种方法中完成:在调用完成处理程序之前将提供通知
func userNotificationCenter( _ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
completionHandler([.banner, .sound])
}
吗?
I would like to change some parameters of Push Notification without changing payload from backend side.
So the app receives a push notification:
{
"Simulator Target Bundle": "com.test.iphone.driver.test",
"aps":{
"alert":"This is Alert.",
"sound":"default"
}
}
But I need to change sound in code to "custom.mp3" before performing notification.
It should be done in this method: willPresent notification before calling completion handler
func userNotificationCenter( _ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
completionHandler([.banner, .sound])
}
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论