ios - Displaying Push Notification Badges Without Notification Service Extension
问题描述
The origin of my problem is that I am not able to test push messages on real devices because of a problem that seems to be an Xcode bug, but this is not the subject now. I just added this to answer why I can't test my implementation normally.
So I have the push notifications implemented in my iOS app with the OneSignal SDK. Based on their setup guide they recommend to create a "Notification Service Extension"
which also caused issues (with the provisioning profile) in my app, that I couldn't fix yet. Therefore I decided to skip adding the extension that means I won't be able to use some specific features, like sending images and altering the badges. I don't care about sending images, but badges would be a must.
My question is that adding a "Notification Service Extension"
is really required to manipulate the badges for iOS 11/12/13? My goal is to just simply display "1"
on the app icon when the client receives a push message. 2-3 years ago when I previously implemented push notifications I didn't need any magic except the below line:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1]
}
Did this change? Or will it display a badge with the number of 1
and I don't have to be afraid about it?
解决方案
ios13 不允许将 PushKit 用于非 VOIP 场景。您必须在他们做广告时添加 NSE。它不再只是用于图像。
推荐阅读
- emscripten - 如何使用 emscripten 构建 PDFium
- sql - 2个坐标之间的距离
- java - 在 weblogic 控制台上查看 eclipse 链接 JPA 执行的 SQL 查询或使用 log4j 配置的日志文件
- javascript - 为什么我的 CSS Flip-Card 背面输入聚焦于点击?
- amazon-web-services - 错误:属性 LoadBalancerAttributes 的值必须是 List 类型
- sql - 为什么从表中删除在 PostgreSQL 中不起作用
- excel - VB代码只在第一行工作,请指教
- android - Android - 如何仅滚动状态栏后面的图像
- flask - 更改 Authlib 中的 authenticate_token 以使用授权服务器验证令牌
- python - 如何将“\t”合并到我的 for 循环输出中?