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

setApplicationIconBadgeNumber with NaN count causes crash #2918

Open
chriscant opened this issue May 26, 2020 · 0 comments
Open

setApplicationIconBadgeNumber with NaN count causes crash #2918

chriscant opened this issue May 26, 2020 · 0 comments

Comments

@chriscant
Copy link
Contributor

Expected Behaviour

Passing NaN as count parameter to setApplicationIconBadgeNumber in iOS should not crash.

Actual Behaviour

Passing NaN as count to setApplicationIconBadgeNumber in iOS causes the app to die.

Steps to Reproduce

Set up the plugin in iOS (including registration and notification handlers).

From code (but not in notification handler in my case) call setApplicationIconBadgeNumber with NaN for count parameter.

Passing JavaScript value Not a Number NaN causes the plugin and app to crash.
Passing a string, a float or a negative integer does not cause a crash.

Platform and Version

Confirmed on iOS 13.4.1 and iOS 12.4.6 on two separate iPhones: 5S and SE(old).

Cordova CLI version and cordova platform version

cordova --version: 9.0.0
cordova platform version ios: 5.1.1

Plugin version

2.3.0

Sample Code that illustrates the problem

const mobilePush = window.PushNotification.init({ios{...}})
...
mobilePush.setApplicationIconBadgeNumber(function () { }, function () { }, NaN)

Logs taken while reproducing problem

I can attach a log if need be.

Fix

I can do a PR to fix if you wish.
It would be simplest to do the fix in /www/push.js
However fixing instead in /src/ios/PushPlugin.m is also possible.

Fixing this might avoid someone wasting hours like I did if they accidentally pass an invalid number.

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

No branches or pull requests

1 participant