Open chriscant opened 4 years ago
Passing NaN as count parameter to setApplicationIconBadgeNumber in iOS should not crash.
Passing NaN as count to setApplicationIconBadgeNumber in iOS causes the app to die.
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.
NaN
Confirmed on iOS 13.4.1 and iOS 12.4.6 on two separate iPhones: 5S and SE(old).
cordova --version: 9.0.0 cordova platform version ios: 5.1.1
2.3.0
const mobilePush = window.PushNotification.init({ios{...}}) ... mobilePush.setApplicationIconBadgeNumber(function () { }, function () { }, NaN)
const mobilePush = window.PushNotification.init({ios{...}})
mobilePush.setApplicationIconBadgeNumber(function () { }, function () { }, NaN)
I can attach a log if need be.
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.
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.