Code Monkey home page Code Monkey logo

rnfirebasev7's People

Contributors

tranhonghan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rnfirebasev7's Issues

the notification at background and quit state, not open the app after it clicked

i have a issue, it's my first time using push notifcation on my react project.
the remote foreground notification is success i can receive the notification and i can click it, but when the app is at background/quit state i still get the remote notification but after i clicked it nothing happen.

i do excatly like you do :

createNotificationListeners = (onRegister, onNotification, onOpenNotification) => {

    // When the application is running, but in the background
    messaging()
    .onNotificationOpenedApp(remoteMessage => {
        console.log('FCMService onNotificationOpenedApp Notification caused app to open from background state:',remoteMessage)
        if (remoteMessage) {
            const notification = remoteMessage.notification
            onOpenNotification(notification)
            // this.removeDeliveredNotification(notification.notificationId)
        }
    });

     // When the application is opened from a quit state.
    messaging()
    .getInitialNotification()
    .then(remoteMessage => {
        console.log('FCMService getInitialNotification Notification reopen app at quit state:',remoteMessage)

        if (remoteMessage) {
            const notification = remoteMessage.notification
            onOpenNotification(notification)
            //  this.removeDeliveredNotification(notification.notificationId)
        }
    });

    // Foreground state messages
    this.messageListener = messaging().onMessage(async remoteMessage => {
        console.log('FCMService A new FCM message arrived!', remoteMessage);
        if (remoteMessage) {
            let notification = null
            if (Platform.OS === 'ios') {
                notification = remoteMessage.data.notification
            } else {
                notification = remoteMessage.notification
            }
            onNotification(notification)
        }
    });

Background : No background message handler has been set. Set a handler via the "setBackgroundMessageHandler" method. where i supposed to place 'setBackgroundMessageHandler'?

quit state :

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
[Wed Mar 10 2021 14:27:08.789] WARN No task registered for key ReactNativeFirebaseMessagingHeadlessTask

Notification popup doesn't show when app is in foreground.

localNotificationService.showNotification doesn't create popup when app is in foreground.

useEffect(() => {
fcmService.registerAppWithFCM()
fcmService.register(onRegister, onNotification, onOpenNotification)
localNotificationService.configure(onOpenNotification)

function onRegister(token) {
console.log("[App] onRegister: ", token)
}

function onNotification(notify) {
console.log("[App] onNotification: ", notify)
const options = {
soundName: 'default',
playSound: true,
}
localNotificationService.showNotification(
0,
notify.title,
notify.body,
notify,
options
)
}

How to save notifications to db when it arrived?

i just added realm insert code part to insert the arriving notifications to my local db. but it is only works when app is in foreground. it is not working when app is in background. what is the function that call up when notification arrived in background?

`function onNotification(notify) {
//console.log("[App] onNotification: ", notify)

        realm.write(() => {
            console.log('on notification')
            var ID =
                realm.objects('notifications').sorted('notify_id', true).length > 0
                    ? realm.objects('notifications').sorted('notify_id', true)[0]
                    .notify_id + 1
                    : 1;
            realm.create('notifications', {
                notify_id: ID,
                notify_title: notify.title,
                notify_body: notify.body,
                notify_time: formatAMPM(new Date),
            });
        });

        const options = {
            soundName: 'default',
            playSound: true //,
            // largeIcon: 'ic_launcher', // add icon large for Android (Link: app/src/main/mipmap)
            // smallIcon: 'ic_launcher' // add icon small for Android (Link: app/src/main/mipmap)
        }
        localNotificationService.showNotification(
            0,
            notify.title,
            notify.body,
            notify,
            options
        )
    }`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.