首页 > 解决方案 > 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?

标签: iosobjective-conesignal

解决方案


ios13 不允许将 PushKit 用于非 VOIP 场景。您必须在他们做广告时添加 NSE。它不再只是用于图像。


推荐阅读