Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit e80d36a

Browse files
committed
Fix #1676
1 parent 7b5f945 commit e80d36a

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
1212

1313
### Fixed
1414

15+
## [6.1.1] 2020-09-29
16+
17+
### Fixed
18+
19+
- (Android) Fix a crash when the application is in background [#1676](https://github.com/zo0r/react-native-push-notification/issues/1676)
20+
1521
## [6.1.0] 2020-09-28
1622

1723
### Features

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@
3131

3232
public class RNReceivedMessageHandler {
3333
private FirebaseMessagingService mFirebaseMessagingService;
34-
private RNPushNotificationConfig config;
3534

3635
public RNReceivedMessageHandler(@NonNull FirebaseMessagingService service) {
3736
this.mFirebaseMessagingService = service;
38-
this.config = new RNPushNotificationConfig(service.getApplication());
3937
}
4038

4139
public void handleReceivedMessage(RemoteMessage message) {
@@ -46,17 +44,19 @@ public void handleReceivedMessage(RemoteMessage message) {
4644
// data has it
4745
if (remoteNotification != null) {
4846
// ^ It's null when message is from GCM
47+
RNPushNotificationConfig config = new RNPushNotificationConfig(mFirebaseMessagingService.getApplication());
48+
4949
bundle.putString("title", remoteNotification.getTitle());
5050
bundle.putString("message", remoteNotification.getBody());
5151
bundle.putString("sound", remoteNotification.getSound());
5252
bundle.putString("color", remoteNotification.getColor());
5353
bundle.putString("tag", remoteNotification.getTag());
54-
54+
5555
if(remoteNotification.getChannelId() != null) {
5656
bundle.putString("channelId", remoteNotification.getChannelId());
5757
}
5858
else {
59-
bundle.putString("channelId", this.config.getNotificationDefaultChannelId());
59+
bundle.putString("channelId", config.getNotificationDefaultChannelId());
6060
}
6161

6262
Integer visibilty = remoteNotification.getVisibility();
@@ -157,6 +157,7 @@ private void handleRemotePushNotification(ReactApplicationContext context, Bundl
157157

158158
Application applicationContext = (Application) context.getApplicationContext();
159159

160+
RNPushNotificationConfig config = new RNPushNotificationConfig(mFirebaseMessagingService.getApplication());
160161
RNPushNotificationHelper pushNotificationHelper = new RNPushNotificationHelper(applicationContext);
161162

162163
boolean isForeground = pushNotificationHelper.isApplicationInForeground();
@@ -171,7 +172,7 @@ private void handleRemotePushNotification(ReactApplicationContext context, Bundl
171172
jsDelivery.notifyRemoteFetch(bundle);
172173
}
173174

174-
if (this.config.getNotificationForeground() || !isForeground) {
175+
if (config.getNotificationForeground() || !isForeground) {
175176
Log.v(LOG_TAG, "sendNotification: " + bundle);
176177

177178
pushNotificationHelper.sendToNotificationCentre(bundle);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-push-notification",
3-
"version": "6.1.0",
3+
"version": "6.1.1",
44
"description": "React Native Local and Remote Notifications",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)