Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Badge is shown on iOS even though it was not configured #1141

Open
Alex-Sessler opened this issue Aug 3, 2016 · 6 comments
Open

Badge is shown on iOS even though it was not configured #1141

Alex-Sessler opened this issue Aug 3, 2016 · 6 comments

Comments

@Alex-Sessler
Copy link
Contributor

Alex-Sessler commented Aug 3, 2016

Expected Behaviour

Push Notifications are received, no badge is set.

Actual Behaviour

Push Notifications are received, Badge is always set to 1. Even after reinstalling the app, the badge is still there.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iPhone 6, iOS 9.3.3

Cordova CLI version and cordova platform version

Cordova 6.2.0
cordova-ios 4.1.1

Plugin version

1.7.0

Sample Code that illustrates the problem

I've configured the plugin like that:
window.push = window.PushNotification.init({ android: { senderID: ENV.gcmId, icon: 'noticon', clearNotifications: false, forceShow: true, clearBadge: true, }, ios: {} });

So through debugging i found some very strange behaviour.
In the didRegisterForRemoteNotificationsWithDeviceToken callback in PushPlugin.m the enabledRemoteNotificationTypes are checked. For me with this configuration (no badge, alert and sound configured), i get a 1 for rntypes, which ends up evaluating true with UIRemoteNotificationTypeBadge, even though UIRemoteNotificationTypeBadge was never registered for. I am fairly certain, that this is the cause for the badge number being set.
Unfortunately I didn't understand the code entirely (I'm no iOS/Obj-C developer), so it's hard for me to see what side effects this could have or what this could break.

Thanks a lot
Alex

badge

@Alex-Sessler
Copy link
Contributor Author

Alex-Sessler commented Aug 8, 2016

@macdonst According to your API doc, badge on iOS is disabled by default (badge attribute). Is that correct? Or will I have to disable it somehow through config? #1143 Also initializes ios with no parameters and expects the badge to show up. Who is right here?
Also, clearBadge seems to work for me on ios.

@DavidSunny
Copy link

Try this.

  1. install [v 0.7.2] https://github.com/katzer/cordova-plugin-badge
  2. insert the following code into your app.
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("resume", onDeviceForeground, false);

function onDeviceReady() {
  cordova.plugins.notification.badge.set(0);
}
function onDeviceForeground() {
  cordova.plugins.notification.badge.set(0);
}

@Alex-Sessler
Copy link
Contributor Author

Alex-Sessler commented Aug 8, 2016

I don't need an extra plugin to accomplish these things, this plugin supports setting the badge number.

In the API Docs for ios, there is an optional attribute "ios.badge", that is false by default and it's functionality is specified like that:

If true the device sets the badge number on receipt of notification. Note: the value you set this option to the first time you call the init method will be how the application always acts. Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>App Name. This is normal iOS behaviour.

So either the doc is incorrect or there is a bug in the plugin. My payload does not include anything related to "badge" as well.

@ClementBu
Copy link

Hello,
I am having the same issue with version 1.8.3 of the plugin.
I have set iOS.badge option to false but still it enables the badge on the app.

Has this been fixed on later versions than 1.8.3? (I don't want to try before I know if it has been fixed because I have to update cordova and I'm afraid it may cause my build to fail).

Thanks in advance.

@gitlovenotwar
Copy link

I am having the same problem. It has always have a badge number(1) even installing/reinstalling the app. Any fix to this?

@stale
Copy link

stale bot commented Jun 3, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

5 participants