question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON value '<null>' of type NSNull cannot be converted to NSNumber

See original GitHub issue

Setting a scheduled notification works fine the first time. To update notification time, I’m using the following snippet and it fails with the error shown in the screenshot.

    PushNotification.cancelAllLocalNotifications()
    PushNotification.localNotificationSchedule({
      message: 'My notification message.',
      date,
      repeatType: 'day'
    });

PS. I’m using the master branch.

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
pigflymooncommented, Jun 11, 2017

I came into this issue too and tried to debug it and found that /node_modules/react-native-push-notification/index.js

const iosDetails = {
			fireDate: details.date.toISOString(),
			alertBody: details.message,
			soundName: soundName,
			applicationIconBadgeNumber: parseInt(details.number, 10),
			userInfo: details.userInfo,
			repeatInterval: details.repeatType
		}

in my js I didn’t set number for local notification

  PushNotification.localNotificationSchedule({
                message: "My Notification Message",
                date: date,
             });

so when code execute parseInt(undefined, 10), it will cause an error so I guess that’s why it finally comes out this issue.

Solution1 :Then I tried to add a line of code to check number value as this:

	if(!details.number){
			details.number = 0;
		}
		const iosDetails = {
			fireDate: details.date.toISOString(),
			alertBody: details.message,
			soundName: soundName,
			applicationIconBadgeNumber: parseInt(details.number, 10),
			userInfo: details.userInfo,
			repeatInterval: details.repeatType
		}

Then solve this issue.

Solution2: or just in my js set number a value.

  PushNotification.localNotificationSchedule({
                message: "My Notification Message",
                date: date,
                number: 0
            });

So please have a look if my tips is all right. Thanks @zo0r

5reactions
bebz229commented, May 9, 2017

Hello @a-koka check this

I make it short in your notification options add number : anyNumberYouWantIGuess

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON value '<null>' of type NSNull cannot be converted to ...
my problem was with source of the images that i had in my component. i had tell the image components to pass null...
Read more >
JSON value '<null>' of type NSNull cannot be ... - GitHub
Description My react-native app is working fine in android without any problem. But when I run it in IOS simulator, this error comes...
Read more >
JSON VALUE '<NULL>' of type nsnull cannot be converted to ...
Coding example for the question react native iOS - JSON VALUE ' ' of type nsnull cannot be converted to a valid url-React...
Read more >
JSON value of type NSnull cannot be converted to NSString?
Hello Firebase, I have strange error. react-native run-android works fine without error. but react-native run-ios failed with JSON value of  ...
Read more >
iOS : JSON value 'null' of type NSNull cannot be converted to ...
iOS : JSON value ' null' of type NSNull cannot be converted to NSString [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found