react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
741 stars 285 forks source link

1.7.1 error: 'Invalid parameter not satisfying: identifier != nil' was thrown while invoking addNotificationRequest #219

Closed joebernard closed 3 years ago

joebernard commented 3 years ago

I get this error by trying to schedule a local notification using the new addNotificationRequest method.

'Invalid parameter not satisfying: identifier != nil' was thrown while invoking addNotificationRequest on target RNCPushNotificationIOS with params ( { alertBody = "my alert body"; alertTitle = "my alert title"; fireDate = "2020-10-28T21:14:07.691+00:00"; userInfo = { data = { id = "febab689-9b96-afaa-11eb-8931d4e1699f"; myData: 'some data' }; }; } )

The stack trace references this line as the culprit.

I am calling it like this:

// first cancel any existing requests
PushNotificationIOS.cancelLocalNotifications(userInfo);
// schedule new push notification
PushNotificationIOS.addNotificationRequest({
  fireDate,
  alertTitle,
  alertBody,
  userInfo,
});

Workaround: If I rollback to 1.6.1 and use scheduleLocalNotification instead of addNotificationRequest the problem goes away.

Ravi448 commented 3 years ago

@joebernard you need to set id in addNotificationRequest params. You can pass some dynamic id like -

id: new Date().toString()