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.

Repeating too many times on Android

See original GitHub issue

versions

react-native-push-notification: 2.2.1 React Native: 0.41.2 Android: 6

problem

When I specify repeatType in my localNotification setting object, the notification repeats constantly every 1~2 seconds.

Here is how I am using this package. The code below is fired once and once only:

PushNotification.localNotification({
    /* Android Only Properties */
    autoCancel: true,
    largeIcon: 'ic_launcher',
    smallIcon: 'ic_notification',
    bigText: 'foo', // (optional) default: 'message' prop
    // subText: 'This is a subText', // (optional) default: none
    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
    ongoing: false, // (optional) set whether this is an 'ongoing' notification

    /* iOS only properties */
    // alertAction: // (optional) default: view
    // category: // (optional) default: null
    // userInfo: // (optional) default: null (object containing additional notification data)

    /* iOS and Android properties */
    title: 'New exercise', // (optional, for iOS this is only used in apple watch, the title will be the app name on other iOS devices)
    message: 'foo', // (required)
    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)
    // date: new Date(),
    repeatType: 'hour', // (Android only) Repeating interval. Could be one of `week`, `day`, `hour`, `minute, `time`. If specified as time, it should be accompanied by one more parameter 'repeatTime` which should the number of milliseconds between each interval
    // actions: '['Yes', 'No']',  // (Android only) See the doc for notification actions to know more
  });

No matter what the value is for repeatType the notification repeats constantly every 1~2 seconds. I tried to include date but doing so did not fix the problem. If I remove repeatType from the object, the problem goes away and notification shows once.

Here is my logcat:

...
02-23 12:08:08.232 17656-17656/com.flowmadapp D/RNPushNotification: Repeating notification with id -992659542 at time 162000000
02-23 12:08:08.234 17656-17656/com.flowmadapp D/RNPushNotification: Storing push notification with id -992659542
02-23 12:08:08.238 17656-17656/com.flowmadapp D/RNPushNotification: Setting a notification with id -992659542 at time 162000000
02-23 12:08:08.248 17656-17656/com.flowmadapp I/RNPushNotification: NotificationPublisher: Prepare To Publish: 805127505, Now Time: 1487812088248
02-23 12:08:08.267 17656-17656/com.flowmadapp D/RNPushNotification: Repeating notification with id 805127505 at time 216000000
02-23 12:08:08.270 17656-17656/com.flowmadapp D/RNPushNotification: Storing push notification with id 805127505
02-23 12:08:08.273 17656-17656/com.flowmadapp D/RNPushNotification: Setting a notification with id 805127505 at time 216000000
...

Any ideas?

more info

I had to upgrade build.gradle due to the issues related to https://github.com/zo0r/react-native-push-notification/issues/252

android/app/build.gradle

dependencies {
   ...
    compile "com.android.support:appcompat-v7:23.4.0"
    compile ('com.google.android.gms:play-services-gcm:9.0.1') { force = true; }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
lukewlmscommented, Jun 10, 2018

I suspect you had a date set in the past.

In iOS if you set a past date with recurring, it will only show future reminders; however, Android will try to “catch up” and show every “missed” notification (which in our case was thousands).

Make sure to set ONLY future dates when setting up a repeated notification.

4reactions
peterchibunnacommented, May 4, 2018

Remove the repeatType option. I think there’s a bug around it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Stop Sending Duplicate Text Messages on Android
A variety of problems can cause duplicate messages on Android and this article will teach you how to fix that from happening.
Read more >
[Solved] How to Unlock Android Phone after Too Many Pattern ...
Solution 1.​​ Follow the steps below on how you can unlock an Android phone via Gmail. Attempt lock screen pattern several times until...
Read more >
Same text going out multiple times | T-Mobile Community
Uninstall any downloaded messaging apps. Some of these can cause double texts. For Android devices, clear the app cache and data of the...
Read more >
Android WorkManager PeriodicWorkRequest repeating too soon
Periodic work has a minimum interval of 15 minutes. If it runs every 3-6 minutes, you have many workManagers. You forgot to cancel...
Read more >
Touch & hold delay - Android Accessibility Help
Open your device's Settings app . Tap Accessibility and then Touch & hold delay. Select Short, Medium, or Long. More about the "touch...
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