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.

Is it possible to attach data to localNotificationSchedule?

See original GitHub issue

Question

I don’t know if I am missing anything but this would solve a pain I’m going through now. For example: how could I add the notification type (i.e. say entryNotification or challengeNotification) when scheduling the notification? Then I could access it in the data prop in onNotification: notification => {}

Example

PushNotification.localNotificationSchedule({
      /* Android Only Properties */
      id: generatedId, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
      // largeIcon: "@mipmap/ic_notif", // (optional) default: "ic_launcher"
      smallIcon: "@mipmap/ic_notif", // (optional) default: "ic_notification" with fallback for "ic_launcher"
      vibrate: true, // (optional) default: true
      vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
      priority: "high", // (optional) set notification priority, default: high
      visibility: "private", // (optional) set notification visibility, default: private
      importance: "high", // (optional) set notification importance, default: high
      allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
      ignoreInForeground: false, // (optional) if true, the notification will not be visible when the app is in the foreground (useful for parity with how iOS notifications appear)

      /* iOS only properties */
      alertAction: "view", // (optional) default: view
      userInfo: {
        id: generatedId,
      }, // (optional) default: {} (using null throws a JSON value '<null>' error)

      /* iOS and Android properties */
      
        /* LOOKING FOR SOMETHING LIKE THIS */
      data: {
        notificationType: 'challengeNotification'
      },

      date: updatedDate,
      repeatType: repeatType,
      message: strings.DashboardComponent.challengeNotificationBody,
      title: isCustomChallenge ? strings.DashboardComponent.customChallengeNotificationTitle : challengeObj.notificationTitle,
    });

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

4reactions
AlphaGolf33commented, Nov 4, 2020

I just figured out that I can reach it by using the field userInfo 😅

0reactions
github-actions[bot]commented, Nov 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create local notification with an end date - Stack Overflow
For example: import PushNotification from 'react-native-push-notification'; PushNotification.localNotificationSchedule({ id: "1", message: "My ...
Read more >
Scheduling a Notification Locally from Your App
Create and schedule notifications from your app when you want to get the user's attention. Overview. Use local notifications to get the user's...
Read more >
react-native-push-notification - npm
NOTE: localNotification() works without changes in the application part, while localNotificationSchedule() only works with these changes:.
Read more >
flutter_local_notifications | Flutter Package - Pub.dev
A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform.
Read more >
React Native Local Push Notifications | by Saad Khan - Medium
First, I am going to install the notification package. yarn add react-native-push- ... Don't forget to pod install for iOS. ... <meta-data ......
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