From 1f978554a3a6347bdcf80af180e4d70f50d80489 Mon Sep 17 00:00:00 2001 From: Boris Tacyniak Date: Mon, 3 Aug 2020 20:47:13 +0200 Subject: [PATCH] Release version 5.0.0. --- .gitignore | 2 ++ CHANGELOG.md | 10 ++++++-- README.md | 23 +++++++++++++++---- .../modules/RNPushNotificationAttributes.java | 5 ---- example/App.js | 7 ++++++ example/NotifService.js | 4 ++++ index.js | 7 +++++- package.json | 2 +- 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index adec98609..0a2cc57b7 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ android/src/main/gen #Debug only google-services.json + +.vscode/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 13d7d6d33..f05211a3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -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 diff --git a/README.md b/README.md index 16f6f4631..3463dc56c 100644 --- a/README.md +++ b/README.md @@ -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: + +Buy Me A Coffee ## Supported React Native Versions @@ -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` @@ -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) diff --git a/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationAttributes.java b/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationAttributes.java index 113cb2428..d2e960da9 100644 --- a/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationAttributes.java +++ b/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationAttributes.java @@ -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"; @@ -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); @@ -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; @@ -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); @@ -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); diff --git a/example/App.js b/example/App.js index accf9e4ed..5d2f03973 100644 --- a/example/App.js +++ b/example/App.js @@ -119,6 +119,13 @@ export default class App extends Component { }}> Create or update a channel + { + this.notif.popInitialNotification(); + }}> + popInitialNotification + diff --git a/example/NotifService.js b/example/NotifService.js index 30f918b66..86ea55eec 100644 --- a/example/NotifService.js +++ b/example/NotifService.js @@ -36,6 +36,10 @@ export default class NotifService { ); } + popInitialNotification() { + PushNotification.popInitialNotification((notification) => console.log('InitialNotication:', notification)); + } + localNotif(soundName) { this.lastId++; PushNotification.localNotification({ diff --git a/index.js b/index.js index f72a8b5a2..072dc55ff 100644 --- a/index.js +++ b/index.js @@ -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, }; diff --git a/package.json b/package.json index ad4c56cbd..60258e8b1 100644 --- a/package.json +++ b/package.json @@ -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": {