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.

If app is active shows an alert

See original GitHub issue

When the app is active and receive the notification an alert with the app name appears on screen.

captura de pantalla 2017-10-24 a la s 14 53 29

The code:

componentWillMount(){
    this.fetchData();

    let self = this;

    PushNotification.configure({
      onRegister: function(token) {
          console.log( 'TOKEN:', token );
      },
      onNotification: function(notification) {
        console.log(notification);
        if(notification.userInteraction){
          self.props.navigation.navigate('Single', { data: notification.data, title: notification.data.book_name + ' ' + notification.data.number + ':' + notification.data.chapter } );
        }
      },
      permissions: {
          alert: false,
          badge: false,
          sound: false
      },
      popInitialNotification: false,
      requestPermissions: true,
    });

    AsyncStorage.getItem('notifications', (error, result) => {
      if(result == null){
        AsyncStorage.setItem('notifications', 'true');

        let db = this.openDB();

        db.transaction((tx) => {
          tx.executeSql('SELECT d.*, l.nombre_en, t.verse_text, t.devotional_text FROM datos d INNER JOIN libros l ON l.numero = d.book INNER JOIN textos t ON t.datos = d.id LIMIT 10', [], (tx, results) => {
            let len = results.rows.length;

            let value = 20;
            let currentValue = 0;
            let currentDate = new Date(Date.now() + ((currentValue + value) * 1000));

            for (let i = 0; i < len; i++) {
              let row = results.rows.item(i);

              let title = row.verse_text;
              if(title.length > 60) title = title.substring(0,60) + '...';

              let verseText = row.verse_text;
              let verseReview = row.devotional_text;
              let verseTitle = title;
              let verseBook = row.nombre_en;
              let verseNumber = row.book;
              let verseChapter = row.chapter;

              currentDate = new Date(Date.now() + ((currentValue + value) * 1000));

              let data = {
                id: row.id,
                title: verseTitle,
                text: verseText,
                review: verseReview,
                book_name: verseBook,
                chapter: verseChapter,
                number: verseNumber,
                day: row.day,
                color: row.color
              };

              PushNotification.localNotificationSchedule({
                 title: verseTitle,
                 message: verseTitle,
                 date: currentDate,
                 userInfo: data,
              });

              currentValue = currentValue + value;
            }
          });
        });
      }
    });
  }

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
daominhsangvncommented, Nov 2, 2017

If you’re using react-native-onesignal then try to use following this to disable the notification displays as popup:

OneSignal.inFocusDisplaying(2);
0reactions
github-actions[bot]commented, Oct 18, 2020

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

Get push notification while App in foreground iOS
If the application is running in the foreground, iOS won't show a notification banner/alert. That's by ...
Read more >
Fix notification issues in the Teams Android app
Open the Settings app. · Tap Permissions. · Tap Manage Auto Launch. If you have enabled other apps to auto-launch, you'll see You've...
Read more >
Exposure Notifications: Helping fight COVID-19 - Google
Learn how Exposure Notifications, built by Google and Apple, enable apps to send you a notification if you've likely been exposed to COVID-19....
Read more >
Use notifications on your iPhone or iPad - Apple Support (CA)
Go to Settings and tap Notifications. · Select an app under Notification Style. · Under Alerts, choose the alert style that you want....
Read more >
Camera and doorbell alerts - Google Nest Help
When enabled, you can receive camera alerts as long as you're signed into the app. Away-only notifications. Tap the switch to enable or...
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