React-native-push-notification: details.date.toISOString is not a function

Created on 30 Jun 2017  路  9Comments  路  Source: zo0r/react-native-push-notification

Hello guys , i implemented the push notification in my project but i always get this problem
simulator screen shot jun 30 2017 12 04 37 pm

here's my code :

`componentDidMount(){
codePush.sync({
updateDialog: true,
installMode: codePush.InstallMode.IMMEDIATE
})

let date = new Date(Date.now() + (6 * 1000));

PushNotification.localNotificationSchedule({
  message: "My Notification Message", // (required)
  date: (Platform.OS === 'ios') ? date.toISOString() : date // in 60 secs
})

}`

Note that i only get this problem on ios , android is working fine

Most helpful comment

Do you guys have the latest version? This may be related to the number field not set in the details object which was fixed in this commit
https://github.com/zo0r/react-native-push-notification/commit/6a4f70fa3754e511a7dfad4c86ae58db169e3c79#diff-168726dbe96b3ce427e7fedce31bb0bc

All 9 comments

Don't set date as date.toISOString(). Send the date object as is for both iOS and Android. So, do

let date = new Date(Date.now() + (6 * 1000));

PushNotification.localNotificationSchedule({
  message: "My Notification Message", // (required)
  date: date // in 60 secs
})

@varungupta85 that's the first thing i did but this is what i get :

simulator screen shot jun 30 2017 2 06 47 pm

This is a separate issue. Your earlier call stack was occurring because you were not sending the date object. I don't use this lib for iOS, so I don't know about this call stack.

@varungupta85 yes I'm experiencing the same thing after your suggested change, however, a few months ago Farid's version was working. I'm afraid its broken now. @farid-ouachrar

Can someone have a look at this?

Do you guys have the latest version? This may be related to the number field not set in the details object which was fixed in this commit
https://github.com/zo0r/react-native-push-notification/commit/6a4f70fa3754e511a7dfad4c86ae58db169e3c79#diff-168726dbe96b3ce427e7fedce31bb0bc

Thank you @varungupta85 , it fixed the problem

Just for extra reference: I upgraded to 3.0.0, but it did not fix it.

However, @varungupta85's first suggestion worked for me.

I tried the fix given by @varungupta85 . I've got this error.
simulator screen shot 22-jul-2017 12 24 57 pm

I edited the index.js at /node-modules/react-native-push-notification/index.js

screen shot 2017-07-22 at 12 31 52 pm

I have the same issue, anyone fix it?

Was this page helpful?
0 / 5 - 0 ratings