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.

Timestamp missing in notification banner [Android]

See original GitHub issue

Bug

Timestamp is missing at Android Notification Banner. At the screenshot below, you’ll see timestamp of 1m & 16h is at the top of the notification.

image

Environment info

Tested with Physical Device on Samsung Android OS: Android version 10

react-native info output:

   OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
    Memory: 1.43 GB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.10.0 - /usr/local/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-21 | Google APIs ARM EABI v7a, android-21 | Google APIs Intel x86 Atom_64, android-23 | Google APIs ARM EABI v7a, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom
      Android NDK: 19.2.5345600
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6308749
    Xcode: 11.6/11E708 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5 
  npmGlobalPackages:
    create-react-native-module: 0.19.0
    react-native-cli: 2.0.1

“react-native-push-notification”: “^5.1.1”,

Steps To Reproduce

  1. Send notification to mobile
  2. Upon receive notification banner, pull down notification tray
  3. See notification banner with timestamp …

Describe what you expected to happen:

Expect to see timestamp, eg (now, 4m, 6h)

Reproducible sample code

The following code is under .configure

PushNotification.configure({
onNotification: (notification) => {
PushNotification.localNotification({
              showWhen: true,
              title: notification.data.gcm_title,
              message: notification.data.message,
              userInfo: notification.data,
            })
}

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
TommyLeongcommented, Oct 15, 2020

@Dallas62 I have managed to get the timestamp appear! So the key is to pass new Date().getTime() to when field. We do not need the field usesChronometer, otherwise the timestamp will keep running like a stopwatch.

Thanks for your help! (:

Here’s the final look of the code

PushNotification.localNotification({
              showWhen: true,  // This is probably not needed, since default value is TRUE.
              when: new Date().getTime(),
              title: notification.data.gcm_title,
              message: notification.data.message,
              userInfo: notification.data,
            })
0reactions
TommyLeongcommented, Oct 15, 2020

Yea, i notice that actually. But can you show me an sample value for when field? I tried to add 11:30 AM STRING earlier, didn’t work out.

Update 1.0

I think the timestamp value should be 1320917972 correct?

I actually dived into library by adding .setWhen(System.currentTimeMillis()) to NotificationCompat.Builderwhich end up like …

NotificationCompat.Builder notification = new NotificationCompat.Builder(context, channel_id)
                    .setContentTitle(title)
                    .setTicker(bundle.getString("ticker"))
                    .setVisibility(visibility)
                    .setPriority(priority)
                    .setAutoCancel(bundle.getBoolean("autoCancel", true))
                    .setOnlyAlertOnce(bundle.getBoolean("onlyAlertOnce", false))
                    .setWhen(System.currentTimeMillis());

but still result the same.

Tested with Physical Device

  1. One Plus 5T - Android 10
  2. Samsung Galaxy S9 - Android 10
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't the time show up in notifications? : r/GooglePixel
When I view notifications, the clock in the status bar is replaced with the date, but most of the time I'm interested in...
Read more >
Notifications Overview | Android Developers
When you issue a notification, it first appears as an icon in the status bar. ... Users can swipe down on the status...
Read more >
android - Notification not firing at correct time - Stack Overflow
This is just a timestamp that will be displayed to the user. ... This is not the time when the notification will go...
Read more >
No timestamp in missed call notification - OnePlus Community
When a call is missed, a notification appears in the notification bar. This notification doesn't have the timestamp (eg. "1h") that shows how...
Read more >
Date missing from notification bar [189569006] - Issue Tracker
For exact build reference, please see the attached bugreport.) ... What steps would let us observe this issue? 1. Pulling down the notification...
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