iOS 10 通知内容扩展未加载

人气:228 发布:2022-10-16 标签: apple-push-notifications swift push-notification ios10 unnotificationrequest

问题描述

我有一个简单的应用程序来处理推送通知.我有通知服务扩展工作.我可以发送带有图像 URL 的远程通知并加载它.

I have a bare-bones app to play with push notifications. I have the Notification Service Extension working. I can send a remote notification with an image URL and have it load.

我似乎无法让通知内容扩展正常工作.我已经阅读了多个教程,他们都说,只需从目标菜单创建一个通知内容扩展,然后在通知内容扩展 Info.plist 中设置

I can't seem to get Notification Content Extension working. I've gone through multiple tutorials and they all say, just create a Notification Content Extension from the target menu and then inside the Notification Content Extensions Info.plist set the

UNNotificationCategory

到一些字符串.然后,当您推送通知时,在aps"json 块中确保类别与 UNNotificationCategory 相同.

to some string. Then when you push the notification, inside the "aps" json-block make sure to have category the same as UNNotificationCategory.

当我收到通知时,我尝试向下、向左或向右滑动,但实际上没有任何反应.但是,服务扩展运行良好.

When I receive a notification, I try to swipe it down, left or right and nothing really happens. However, the service extension is working great.

我使用的是带有 ios 10 和 XCode 8.0 的 iPhone 5.我曾经读到过,只有具有 3d 触控功能的设备才能查看内容扩展,但自从 xCode 8 退出测试版后,情况发生了变化.

I am using an iPhone 5 with ios 10 and XCode 8.0. I read that at one point only devices with 3d touch could view the content extension but that has since changed since xCode 8 is out of beta.

有什么想法吗?我该如何去调试这个?我试过在选择了通知扩展的情况下运行应用程序并打印出里面的内容

Any ideas? How can I go about debugging this? I've tried running the app with the Notification Extension selected and printing out stuff inside

didReceive

但我没有任何运气.

推荐答案

尽管我在 stackoverflow 和在线的其他地方读到的内容,扩展推送通知在 iPhone 5 和 IOS 10 上不起作用.我借了 iPhone 6+ 和我的代码运行良好.

Despite what I read elsewhere on stackoverflow and online, expanding the push notification did not work on an iPhone 5 and IOS 10. I borrowed an iPhone 6+ and my code worked fine.

809