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.

Installed correctly but not working

See original GitHub issue

Question

PushNotification.localNotification({ /* Android Only Properties */ channelId: “1”, // (required) channelId, if the channel doesn’t exist, it will be created with options passed above (importance, vibration, sound). Once the channel is created, the channel will not be update. Make sure your channelId is different if you change these options. If you have created a custom channel, it will apply options of the channel. ticker: “My Notification Ticker”, // (optional) showWhen: true, // (optional) default: true autoCancel: true, // (optional) default: true largeIcon: “ic_launcher”, // (optional) default: “ic_launcher”. Use “” for no large icon. largeIconUrl: “https://www.example.tld/picture.jpg”, // (optional) default: undefined smallIcon: “ic_notification”, // (optional) default: “ic_notification” with fallback for “ic_launcher”. Use “” for default small icon. bigText: “My big text that will be shown when notification is expanded”, // (optional) default: “message” prop subText: “This is a subText”, // (optional) default: none bigPictureUrl: “https://www.example.tld/picture.jpg”, // (optional) default: undefined color: “red”, // (optional) default: system default vibrate: true, // (optional) default: true vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000 tag: “some_tag”, // (optional) add tag to message group: “group”, // (optional) add group to message groupSummary: false, // (optional) set this notification to be the group summary for a group of notifications, default: false ongoing: false, // (optional) set whether this is an “ongoing” notification priority: “high”, // (optional) set notification priority, default: high visibility: “private”, // (optional) set notification visibility, default: private 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) shortcutId: “shortcut-id”, // (optional) If this notification is duplicative of a Launcher shortcut, sets the id of the shortcut, in case the Launcher wants to hide the shortcut, default undefined onlyAlertOnce: false, // (optional) alert will open only once with sound and notify, default: false

        when: null, // (optionnal) Add a timestamp pertaining to the notification (usually the time the event occurred). For apps targeting Build.VERSION_CODES.N and above, this time is not shown anymore by default and must be opted into by using `showWhen`, default: null.
        usesChronometer: false, // (optional) Show the `when` field as a stopwatch. Instead of presenting `when` as a timestamp, the notification will show an automatically updating display of the minutes and seconds since when. Useful when showing an elapsed time (like an ongoing phone call), default: false.
        timeoutAfter: null, // (optional) Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled, default: null
      
        messageId: "google:message_id", // (optional) added as `message_id` to intent extras so opening push notification can find data stored by @react-native-firebase/messaging module. 
      
        actions: ["Yes", "No"], // (Android only) See the doc for notification actions to know more
        invokeApp: true, // (optional) This enable click on actions to bring back the application to foreground or stay in background, default: true
      
        /* iOS only properties */
        alertAction: "view", // (optional) default: view
        category: "", // (optional) default: empty string
      
        /* iOS and Android properties */
        id: 0, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
        title: "My Notification Title", // (optional)
        message: "My Notification Message", // (required)
        userInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)
        playSound: false, // (optional) default: true
        soundName: "default", // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
        number: 10, // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
        repeatType: "day", // (optional) Repeating interval. Check 'Repeating Notifications' section for more info.
      });

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
pk936commented, Nov 6, 2020

@nopol10 yes it worked. I did following:

Step 1: I created channel in index js using PushNotification.createChannel( … with a channel id Step 2 : Then I passed the channel id in PushNotification.localNotification({

index.js

PushNotification.configure({
    // (required) Called when a remote or local notification is opened or received
    onNotification: function (notification) {
        console.log('LOCAL NOTIFICATION ==>', notification)
    },

    popInitialNotification: true,
    requestPermissions: Platform.OS === 'ios'
})

PushNotification.createChannel(
    {
        channelId: "not1", // (required)
        channelName: "Channel", // (required)
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
);

AppRegistry.registerComponent(appName, () => AppProvider);

App.js

const LocalNotification = () => {
  PushNotification.localNotification({
    channelId: "not1",
    autoCancel: true,
    bigText:
      'This is local notification demo in React Native app. Only shown, when expanded.',
    subText: 'Local Notification Demo',
    title: 'Local Notification Title',
    message: 'Expand me to see more',
    vibrate: true,
    vibration: 300,
    playSound: true,
    soundName: 'default',
    actions: '["Yes", "No"]'
  })
}
2reactions
nopol10commented, Nov 6, 2020

Did you run PushNotification.createChannel during initialization? (as stated here: https://github.com/zo0r/react-native-push-notification#channel-management-android).

Had the same issue then realized I missed out on doing that

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix: if your Windows Apps are 'Not Installed Correctly'
1. Use an antivirus · Disable your current antivirus. · Reboot your Windows 10 operating system. · After the Windows 10 powers up...
Read more >
How to troubleshoot Windows Installer errors - Microsoft Support
Identify Windows Installer issues · Click Start, click Run, type cmd, and then click Command Prompt. · At the command prompt, type the...
Read more >
How to Fix It Looks Like Windows Didn't Load Correctly
How do I fix Windows startup problems? You can fix it by uninstalling new software or drivers: Insert the Windows bootable drive and...
Read more >
Unable to Install Apps or Software on Windows? Here's What ...
If you still can't install software properly on Windows, go to Settings > Apps > Apps & features and uninstall the current version...
Read more >
Fix an installed Android app that isn't working - Google Support
Isn't working properly. If the app that isn't working is an Instant App, try these troubleshooting steps instead. After each step, restart your...
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