Closed jjdp closed 6 years ago
@jjdp closing this issue due to inactivity.
You can control this behavior using the OneSignal_disable_badge_clearing
boolean setting in Info.plist
.
Please feel free to respond if you are still encountering this issue and I will be happy to reopen and investigate.
This is exactly what is happening to me. I'm up to 70 notification count thus far. I have not fiddled with any of the default settings.
Based on your response Nightsd01, I think you may have misunderstood somewhat. The notification count goes away once you open the app. But then once you receive another notification, it keeps incrementing from where you left off.
I think it's an issue with the http api potentially. When the app initializes, I think a request should be sent to OneSignal telling it to edit the device and return the device's notification count back to 0. I think since that is not happening, the server sdk simply thinks the device is still at the old badge count. SettingOneSignal_disable_badge_clearing
just deals with local behavior.
@scottmas I am guessing you created your app within the last week?
If so, we recently switched iOS badge count logic to happening on the device instead of our backend.
The solution in your case is to add an App Group to your app & extension service (also add the extension service if you haven't done that yet). This will result in a more consistent badge count since the count is being maintained on the device directly.
Please read our docs: https://documentation.onesignal.com/docs/ios-sdk-app-groups-setup
@Nightsd01 I am just now integrating OneSignal React Native into our app today, and I am seeing this same issue despite having created and hooked up both the App Group and Extension Service according to the instructions in the documentation.
Are there any other steps we can take to debug this / check what else might be going wrong here? I've tried doing this manually as well:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
}
But it has the same effect we were already seeing: the icon clears when the app is opened or the notification is clicked, but on the next notification the count is incremented by 1 without being reset (i.e. it goes from 4 -> 0 -> 5).
@cojo I recommend contacting OneSignal support while logged into the dashboard. They can check your app on your account to make sure the new badge increment logic is turned on for it.
@cojo this does mean that either the app group or the extension service aren’t configured correctly. Here are some troubleshooting steps:
When did you create the app on OneSignal’s dashboard? Within the last 3 weeks? If not, it’s using server-side badge logic. Unfortunately, this means that when you manually set the badge count yourself (using setApplicationIconBadgeNumber
), it won’t be reflected in our server so it will get reset the next time the user gets a push from us.
If so, please make sure that the name of your app group is correct. It should be group.(your main app’s bundle id).onesignal
Make sure the extension service is configured correctly by sending rich push notifications, for example with an image attachment. Does the image show up? If not, you’ll want to make sure that the Deployment Target in the extension service matches your main app (but must be at least iOS 10 or higher)
We are having the same issue. Rich push notifications work fine. We did create the app recently. Did you get this fixed @cojo?
Unfortunately I have not had a chance to try sending a rich push notification for our app / confirm if those are working since I last posted here. We did create it within a few days of that post though so it theoretically should be falling under the new logic.
I also confirmed the app group matches re suggestion 2. I think we might not have yet targeted iOS 10 at that time (we were targeting 9) but we are targeting 10 now.
I'll update here next time we have a chance to confirm if it's still broken for us.
Can confirm this is broken for us. I get rich images just fine. The badge count is just broken. We created our account July 12. We are on version 3.2.4 of React Native (the latest is 3.2.5).
In my experience, after adding App Groups capabilities and adding the group keys, the badge count is reset when the notification is tapped.
Is there a way to reset the count manually? I'd like to reset it when our "new" items are dismissed in the app.
@jayporta You can set OneSignal_disable_badge_clearing
to NO
in Info.plist
to disable the automatic badge clearing.
@scottmas The issue you are describing sounds exactly like an issue with the app group not allowing communication between your main app and the extension service, so they get de-synchronized.
Do you happen to have a 2 part bundle ID by chance? (ie. com.test). It's also common to have this issue if your OneSignalNotificationServiceExtension bundle ID isn't exactly the same as your main app's bundle ID (ie. com.test.app
and com.test.app.OneSignalNotificationServiceExtension
).
In any case, what I would suggest is this: in both Info.plist
files (your main app will have one and your extension service will have one as well), set the OneSignal_app_groups_key
to be whatever your app group name is. This should fix the problem.
Thanks, but I don’t want to disable badge clearing, I want to additionally do it programmatically if possible.
On Fri, Aug 10, 2018 at 4:02 PM Brad Hesse notifications@github.com wrote:
@jayporta https://github.com/jayporta You can set OneSignal_disable_badge_clearing to NO in Info.plist to disable the automatic badge clearing.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/geektimecoil/react-native-onesignal/issues/309#issuecomment-412190448, or mute the thread https://github.com/notifications/unsubscribe-auth/AOi1lHe2o7f2BCKpqZLcfU0NNvWJDHoXks5uPebNgaJpZM4PBA6q .
I got the same problem but then i figure out that i forgot to enable App Groups Capabilities in OneSignalNotificationServiceExtension target.
** 1. Under Capabilities enable App Groups for both your main app target as well as the OneSignalNotificationServiceExtension target.
@jayporta that’s fine, but you would still need to set that plist key to prevent the SDK from automatically clearing the count.
Natively you would call UIApplication.shared.setApplicationIconBadgeNumber
to set it to zero yourself.
Thanks
You can set
OneSignal_disable_badge_clearing
toNO
inInfo.plist
to disable the automatic badge clearing.
@Nightsd01 do we set it as NO
or do we set it as <true/>
?
@rothanachoun Thanks man! Helped me.
Please follow https://documentation.onesignal.com/docs/ios-sdk-app-groups-setup in detail.
The name of your app group should be group.{your_bundle_id}.onesignal. So for example, if your application's bundle identifier is com.test.app, your app group name should be group.com.test.app.onesignal.
Assign the group to both target.
- Open your Info.plist file and add a new OneSignal_app_groups_key as a String type.
- Enter the group name you checked in the last step as it's value.
- Make sure to do the same for the Info.plist under the OneSignalNotificationServiceExtension folder.
If anyone looking for an answer, install react-native-push-notification it has the function of getting and setting application badge count, use it.. Just install the package no need to do any setup, and call PushNotification.setApplicationIconBadgeNumber(number: number)
. It will work.
It does not reset when you launch the app. The only time it resets is if the app is in the foreground while you receive a notification. It may have to do with the in app behavior.
Tested with the following: