Skip to content

Commit

Permalink
Release version 5.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dallas62 committed Aug 3, 2020
1 parent ab8e29f commit 1f97855
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ android/src/main/gen

#Debug only
google-services.json

.vscode/
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

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

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

## [Unreleased]

### Breaking changes

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

### Features

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

### Fixed

- (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).
- (Android) `notification.foreground` now return the good value, before the value was `false` most of the time.

## [4.0.0] 2020-07-06

Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
React Native Local and Remote Notifications for iOS and Android


## 🎉 Version 4.0.0 is live ! 🎉
## 🎉 Version 5.0.0 is live ! 🎉

Check out for changes in the CHANGELOG:

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

# Supporting the project

Maintaining this project takes time. To help allocate time, you can Buy Me a Coffee :wink:

<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>

## Supported React Native Versions

Expand Down Expand Up @@ -357,6 +362,18 @@ PushNotification.localNotificationSchedule({
});
```

## Get the initial notification

`PushNotification.popInitialNotification(callback)`

EXAMPLE:

```javascript
PushNotification.popInitialNotification((notification) => {
console.log('Initial Notification', notification);
});
```

## Custom sounds

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

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

## Sending Notification Data From Server

Same parameters as `PushNotification.localNotification()`

## Android Only Methods

`PushNotification.subscribeToTopic(topic: string)` Subscribe to a topic (works only with Firebase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class RNPushNotificationAttributes {
private static final String GROUP = "group";
private static final String GROUP_SUMMARY = "groupSummary";
private static final String MESSAGE_ID = "messageId";
private static final String USER_INTERACTION = "userInteraction";
private static final String PLAY_SOUND = "playSound";
private static final String VIBRATE = "vibrate";
private static final String VIBRATION = "vibration";
Expand Down Expand Up @@ -111,7 +110,6 @@ public RNPushNotificationAttributes(Bundle bundle) {
group = bundle.getString(GROUP);
groupSummary = bundle.getBoolean(GROUP_SUMMARY);
messageId = bundle.getString(MESSAGE_ID);
userInteraction = bundle.getBoolean(USER_INTERACTION);
playSound = bundle.getBoolean(PLAY_SOUND);
vibrate = bundle.getBoolean(VIBRATE);
vibration = bundle.getDouble(VIBRATION);
Expand Down Expand Up @@ -151,7 +149,6 @@ private RNPushNotificationAttributes(JSONObject jsonObject) {
group = jsonObject.has(GROUP) ? jsonObject.getString(GROUP) : null;
groupSummary = jsonObject.has(GROUP_SUMMARY) ? jsonObject.getBoolean(GROUP_SUMMARY) : false;
messageId = jsonObject.has(MESSAGE_ID) ? jsonObject.getString(MESSAGE_ID) : null;
userInteraction = jsonObject.has(USER_INTERACTION) ? jsonObject.getBoolean(USER_INTERACTION) : false;
playSound = jsonObject.has(PLAY_SOUND) ? jsonObject.getBoolean(PLAY_SOUND) : true;
vibrate = jsonObject.has(VIBRATE) ? jsonObject.getBoolean(VIBRATE) : true;
vibration = jsonObject.has(VIBRATION) ? jsonObject.getDouble(VIBRATION) : 1000;
Expand Down Expand Up @@ -248,7 +245,6 @@ public Bundle toBundle() {
bundle.putString(GROUP, group);
bundle.putBoolean(GROUP_SUMMARY, groupSummary);
bundle.putString(MESSAGE_ID, messageId);
bundle.putBoolean(USER_INTERACTION, userInteraction);
bundle.putBoolean(PLAY_SOUND, playSound);
bundle.putBoolean(VIBRATE, vibrate);
bundle.putDouble(VIBRATION, vibration);
Expand Down Expand Up @@ -290,7 +286,6 @@ public JSONObject toJson() {
jsonObject.put(GROUP, group);
jsonObject.put(GROUP_SUMMARY, groupSummary);
jsonObject.put(MESSAGE_ID, messageId);
jsonObject.put(USER_INTERACTION, userInteraction);
jsonObject.put(PLAY_SOUND, playSound);
jsonObject.put(VIBRATE, vibrate);
jsonObject.put(VIBRATION, vibration);
Expand Down
7 changes: 7 additions & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export default class App extends Component {
}}>
<Text>Create or update a channel</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={() => {
this.notif.popInitialNotification();
}}>
<Text>popInitialNotification</Text>
</TouchableOpacity>

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

Expand Down
4 changes: 4 additions & 0 deletions example/NotifService.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export default class NotifService {
);
}

popInitialNotification() {
PushNotification.popInitialNotification((notification) => console.log('InitialNotication:', notification));
}

localNotif(soundName) {
this.lastId++;
PushNotification.localNotification({
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,14 @@ Notifications._transformNotificationObject = function(data, isFromBackground = n
fireDate: Date.parse(data._fireDate),
finish: (res) => data.finish(res)
};

if(isNaN(_notification.fireDate)) {
delete _notification.fireDate;
}

} else {
_notification = {
foreground: ! isFromBackground,
foreground: !isFromBackground,
finish: () => {},
...data,
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-push-notification",
"version": "4.0.0",
"version": "5.0.0",
"description": "React Native Local and Remote Notifications",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 1f97855

Please sign in to comment.