katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.57k stars 1.76k forks source link

Terminating app due to uncaught exception - index 0 beyond bounds for empty array #1657

Closed terminaltor closed 1 month ago

terminaltor commented 6 years ago

All methods returns same error, iOS only: 2018-08-06 10:14:57.086475+0300 Terminating app due to uncaught exception 'NSRangeException', reason: ' -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array'

Ionic, iOS - android is fine!

Expected Behavior

The getAll & schedule methods should work :)

Actual Behavior

Getting this error: 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array

Steps to Reproduce

  1. Make a new project
  2. Install the plugin
  3. Use getAll or schedule method
  4. Debug with XCode

Context

Schedule multiple local notifications for my users

Debug logs

2018-08-06 10:14:57.086475+0300 HebCal [14732:1838811] Terminating app due to uncaught exception 'NSRangeException', reason: ' -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array'

rwillett commented 6 years ago

Whats the code?

mdgs commented 5 years ago

Found the problem at below code local-notification.js:

exports._exec = function (action, args, callback, scope) {
    var fn     = this._createCallbackFn(callback, scope),
        params = [];

    if (Array.isArray(args)) {
        params = args;
    } else if (args) {
        params.push(args);
    }

    exec(fn, null, 'LocalNotification', action, params);
};

getAll will send args 0, not array, and evaluated as false, hence params is empty

marioshtika commented 5 years ago

I have the same problem.