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

Commit 1f97855

Browse files
committed
Release version 5.0.0.
1 parent ab8e29f commit 1f97855

File tree

8 files changed

+46
-14
lines changed

8 files changed

+46
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ android/src/main/gen
4646

4747
#Debug only
4848
google-services.json
49+
50+
.vscode/

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5+
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
76

87
## [Unreleased]
98

109
### Breaking changes
1110

11+
- (Android/iOS) Unify returned values between iOS and Android [#1516](https://github.com/zo0r/react-native-push-notification/pull/1516).
12+
- (Android/iOS) `.popInitialNotification(callback)` now return the same format as `onNotification()`.
13+
- (Android) `popInitialNotification` in `configure()` now trigger only once on app startup, same as iOS.
14+
- (Android) `notification.foreground` now return the good value, before the value was `false` most of the time.
15+
1216
### Features
1317

1418
- (Android) Add function `createChannel` for custom Android channel support [#1509](https://github.com/zo0r/react-native-push-notification/pull/1509)
@@ -18,6 +22,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1822

1923
### Fixed
2024

25+
- (Android) `popInitialNotification` in `configure()` now trigger only once and do not trigger twice `onNotification()` when user press the notification, more details: [#1516](https://github.com/zo0r/react-native-push-notification/pull/1516).
26+
- (Android) `notification.foreground` now return the good value, before the value was `false` most of the time.
2127

2228
## [4.0.0] 2020-07-06
2329

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
React Native Local and Remote Notifications for iOS and Android
77

88

9-
## 🎉 Version 4.0.0 is live ! 🎉
9+
## 🎉 Version 5.0.0 is live ! 🎉
1010

1111
Check out for changes in the CHANGELOG:
1212

1313
[Changelog](https://github.com/zo0r/react-native-push-notification/blob/master/CHANGELOG.md)
1414

15+
# Supporting the project
16+
17+
Maintaining this project takes time. To help allocate time, you can Buy Me a Coffee :wink:
18+
19+
<a href="https://www.buymeacoffee.com/Dallas62" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-blue.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>
1520

1621
## Supported React Native Versions
1722

@@ -357,6 +362,18 @@ PushNotification.localNotificationSchedule({
357362
});
358363
```
359364

365+
## Get the initial notification
366+
367+
`PushNotification.popInitialNotification(callback)`
368+
369+
EXAMPLE:
370+
371+
```javascript
372+
PushNotification.popInitialNotification((notification) => {
373+
console.log('Initial Notification', notification);
374+
});
375+
```
376+
360377
## Custom sounds
361378

362379
In android, add your custom sound file to `[project_root]/android/app/src/main/res/raw`
@@ -660,10 +677,6 @@ Works natively in iOS.
660677

661678
Uses the [ShortcutBadger](https://github.com/leolin310148/ShortcutBadger) on Android, and as such will not work on all Android devices.
662679

663-
## Sending Notification Data From Server
664-
665-
Same parameters as `PushNotification.localNotification()`
666-
667680
## Android Only Methods
668681

669682
`PushNotification.subscribeToTopic(topic: string)` Subscribe to a topic (works only with Firebase)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class RNPushNotificationAttributes {
3636
private static final String GROUP = "group";
3737
private static final String GROUP_SUMMARY = "groupSummary";
3838
private static final String MESSAGE_ID = "messageId";
39-
private static final String USER_INTERACTION = "userInteraction";
4039
private static final String PLAY_SOUND = "playSound";
4140
private static final String VIBRATE = "vibrate";
4241
private static final String VIBRATION = "vibration";
@@ -111,7 +110,6 @@ public RNPushNotificationAttributes(Bundle bundle) {
111110
group = bundle.getString(GROUP);
112111
groupSummary = bundle.getBoolean(GROUP_SUMMARY);
113112
messageId = bundle.getString(MESSAGE_ID);
114-
userInteraction = bundle.getBoolean(USER_INTERACTION);
115113
playSound = bundle.getBoolean(PLAY_SOUND);
116114
vibrate = bundle.getBoolean(VIBRATE);
117115
vibration = bundle.getDouble(VIBRATION);
@@ -151,7 +149,6 @@ private RNPushNotificationAttributes(JSONObject jsonObject) {
151149
group = jsonObject.has(GROUP) ? jsonObject.getString(GROUP) : null;
152150
groupSummary = jsonObject.has(GROUP_SUMMARY) ? jsonObject.getBoolean(GROUP_SUMMARY) : false;
153151
messageId = jsonObject.has(MESSAGE_ID) ? jsonObject.getString(MESSAGE_ID) : null;
154-
userInteraction = jsonObject.has(USER_INTERACTION) ? jsonObject.getBoolean(USER_INTERACTION) : false;
155152
playSound = jsonObject.has(PLAY_SOUND) ? jsonObject.getBoolean(PLAY_SOUND) : true;
156153
vibrate = jsonObject.has(VIBRATE) ? jsonObject.getBoolean(VIBRATE) : true;
157154
vibration = jsonObject.has(VIBRATION) ? jsonObject.getDouble(VIBRATION) : 1000;
@@ -248,7 +245,6 @@ public Bundle toBundle() {
248245
bundle.putString(GROUP, group);
249246
bundle.putBoolean(GROUP_SUMMARY, groupSummary);
250247
bundle.putString(MESSAGE_ID, messageId);
251-
bundle.putBoolean(USER_INTERACTION, userInteraction);
252248
bundle.putBoolean(PLAY_SOUND, playSound);
253249
bundle.putBoolean(VIBRATE, vibrate);
254250
bundle.putDouble(VIBRATION, vibration);
@@ -290,7 +286,6 @@ public JSONObject toJson() {
290286
jsonObject.put(GROUP, group);
291287
jsonObject.put(GROUP_SUMMARY, groupSummary);
292288
jsonObject.put(MESSAGE_ID, messageId);
293-
jsonObject.put(USER_INTERACTION, userInteraction);
294289
jsonObject.put(PLAY_SOUND, playSound);
295290
jsonObject.put(VIBRATE, vibrate);
296291
jsonObject.put(VIBRATION, vibration);

example/App.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ export default class App extends Component {
119119
}}>
120120
<Text>Create or update a channel</Text>
121121
</TouchableOpacity>
122+
<TouchableOpacity
123+
style={styles.button}
124+
onPress={() => {
125+
this.notif.popInitialNotification();
126+
}}>
127+
<Text>popInitialNotification</Text>
128+
</TouchableOpacity>
122129

123130
<View style={styles.spacer}></View>
124131

example/NotifService.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export default class NotifService {
3636
);
3737
}
3838

39+
popInitialNotification() {
40+
PushNotification.popInitialNotification((notification) => console.log('InitialNotication:', notification));
41+
}
42+
3943
localNotif(soundName) {
4044
this.lastId++;
4145
PushNotification.localNotification({

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,14 @@ Notifications._transformNotificationObject = function(data, isFromBackground = n
359359
fireDate: Date.parse(data._fireDate),
360360
finish: (res) => data.finish(res)
361361
};
362+
363+
if(isNaN(_notification.fireDate)) {
364+
delete _notification.fireDate;
365+
}
366+
362367
} else {
363368
_notification = {
364-
foreground: ! isFromBackground,
369+
foreground: !isFromBackground,
365370
finish: () => {},
366371
...data,
367372
};

package.json

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

0 commit comments

Comments
 (0)