evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

Need help with MismatchedSenderId #530

Open SharanyaRao91 opened 7 years ago

SharanyaRao91 commented 7 years ago

We are on RN 0.44 for Android 6, foregroud/background and running. Getting a mismatchedsenderId. Was hoping someone could shed some light on it.

Also: The Server Key from the Firebase console: DOES IT HAVE to be the legacy or the non-legacy server key?

Here is the call:

var fcm = new FCM('<Server Key from the Firebase console:  DOES IT HAVE to be the legacy or the non-legacy server key?');
**var registrationId = ‘e7………………..’

        var message = {
            to: registrationId,

                data: {
                    action : 'message',
                sender: '<SENDERID from the firebase console',
                    content:{
                        key1: "k1",
                        key2: "k2",
                    }

            },
            notification: {
                title: 'Title of the notification',
                    body: 'Body of the notification'
            }
        };

        fcm.send(message)
            .then(function(response){
                console.log("Successfully sent with response: ", response);
                def.resolve({Error: false, message: response})
            })
            .catch(function(err){
                console.log("Something has gone wrong!");
                def.resolve({Error: true, message: "Something has gone wrong !", error: err})
                console.error(err);
            })

** The following image is from the Firebase console.
image

evollu commented 7 years ago

according to firebase new server key is preferred but both should work. Have no clue about the sender id, sounds like a question for Firebase team