evollu / react-native-fcm

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

One app handle other app's push notification #640

Open vishaljadav24 opened 6 years ago

vishaljadav24 commented 6 years ago

# Step to produce issue:

evollu commented 6 years ago

are you sure you are using the right server key? You shouldn't get the same fcm token for different app, even reinstalling the app will generate a different token

vishaljadav24 commented 6 years ago

Yes. I am sure for server key.

evollu commented 6 years ago

Server key is different by project but Fcm token is same. can you verify it? your 2 apps have different app id right?

vishaljadav24 commented 6 years ago

Yes @evollu , I verify it and app id also different. I searched a lot for this issue. But nothing found which solved my issue. So please help me.

evollu commented 6 years ago

try delete and reinstall both apps and see if you get the same fcm token. They should be different

vishaljadav24 commented 6 years ago

I got different Fcm tokens after uninstall app but issue not solve.

vishaljadav24 commented 6 years ago

We made some changes in code as per below and it worked! For Title and Text send those data under notification Key.

{
    "to": "fcmToken",
    "priority": "high",
    "data": {
        "type": "BOOK",
        "delivery_id": 71,
        "start_time": 1510817811,
        "end_time": 1510817840,
                "sound": "default",
                "title": "New Delivery Booked!",
                "text": "New delivery is booked accept before its too late!"
    }
}

changable code


{
    "to": "fcmToken",
    "priority": "high",
    "data": {
        "type": "BOOK",
        "delivery_id": 71,
        "start_time": 1510817811,
        "end_time": 1510817840,
                "sound": "default"
    },
    "notification": {
            "title": "New Delivery Booked!",
                "text": "New delivery is booked accept before its too late!"        
    }
}
evollu commented 6 years ago

cool... I don't know the real cause though...perhaps some issue with firebase

vishaljadav24 commented 6 years ago

I face this issue again. The issue comes when one app is running in background and second app is in the foreground. For both the app push is coming. Attaching the screenshot for better understanding. If I kill the second app and only one app is in active state then issue is not coming. fcm_push_issue

evollu commented 6 years ago

ok. I might know what is going on now. Broadcast event seems to be sent to all applications so

  1. if one of your app received refresh token event, the other app receives too. this might explain why you have same firebase token for 2 apps. Can you verify that?
evollu commented 6 years ago

@vishaljadav24 try master branch. it should be fixed now

pmemids commented 5 years ago

hi, I am also working on two apps. In my case I receive notification for one app at a time on same device if App A is installed first and B is installed after that so I will receive notification for App A. If App B is installed first then I will receive notification for App B not for A in same device. I am unable to identify the problem please help my OS version is latest one Oreo