evollu / react-native-fcm

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

topic notification doesnt show after upgrade to new react native fcm version #915

Closed mrifni closed 6 years ago

mrifni commented 6 years ago

My previous app used get topic notifications but after upgrading the library versions i just get this below message in the logcat.

MessagingService: Remote message received

My previous library versions (working with this versions) "react": "16.0.0", "react-native": "0.51.0", "react-native-fcm": "^13.3.1", "react-navigation": "^1.0.0-beta.29",

New library versions(stopped working with this versions) "react": "16.3.1", "react-native": "0.55.3", "react-native-fcm": "14.1.3", "react-navigation": "^1.5.11",

I using nexus 6 and oneplus 5 mobiles to test. I tried in both forground and background, just receiving the message MessagingService: Remote message received in log cat but no notifications are shown. I am sending topic notifications.

This is my backend java code using to send the message

// topic either article, message etc... Message.Builder builder = Message.builder() .putData("type", topic) .putData("id", id) .putData("title", title) .setApnsConfig(ApnsConfig.builder() .setAps(Aps.builder() .setBadge(42) .build()) .build()) .setAndroidConfig(AndroidConfig.builder() .setTtl(606024*10) // 10 days .setPriority(AndroidConfig.Priority.HIGH) .build()) .setTopic(topic); if(StringUtils.isNotBlank(body)){ builder.putData("body", body); } if(StringUtils.isNotBlank(image)) { builder.putData("image", image); } Message message = builder.build(); String response = FirebaseMessaging.getInstance().sendAsync(message).get();

mrifni commented 6 years ago

this is nothing to do with the version, fcm message wasnt working because of body is required. and my message wasnt sending a body. so notification didnt show up.