From e1d0c8095f1989219e85281828a0dc3299c7e9a5 Mon Sep 17 00:00:00 2001 From: yogevbd Date: Wed, 2 Oct 2019 14:05:39 +0300 Subject: [PATCH] Merge from master branch --- .grenrc.js | 2 +- CHANGELOG.gren.md | 40 +++++++++++++++++++ .../NotificationManagerCompatFacade.java | 2 +- example/android/build.gradle | 2 +- .../project.pbxproj | 37 +++-------------- lib/android/app/src/main/AndroidManifest.xml | 2 +- .../core/notification/PushNotification.java | 18 ++++++++- package.json | 15 +++---- scripts/release.js | 4 +- scripts/test-unit.js | 2 +- 10 files changed, 76 insertions(+), 48 deletions(-) create mode 100644 CHANGELOG.gren.md diff --git a/.grenrc.js b/.grenrc.js index b0bad8a..8e8cf25 100644 --- a/.grenrc.js +++ b/.grenrc.js @@ -21,7 +21,7 @@ module.exports = { "snapshot" ], dataSource: "prs", - changelogFileName: "CHANGELOG.gren.md", + changelogFilename: "CHANGELOG.gren.md", tags: "all", override: true, generate: true diff --git a/CHANGELOG.gren.md b/CHANGELOG.gren.md new file mode 100644 index 0000000..95d385f --- /dev/null +++ b/CHANGELOG.gren.md @@ -0,0 +1,40 @@ +# Changelog + +## 2.1.3 (22/09/2019) + +#### Enhancements: + +- Autogenerate changelog using github-release-notes [#382](https://github.com/wix/react-native-notifications/pull/382) + +#### Bug Fixes: + +- Fixing white square icon and annotation error [#379](https://github.com/wix/react-native-notifications/pull/379) + +--- + +## 3.0.0-alpha.0 (15/09/2019) +*No changelog for this release.* + +--- + +## 2.1.0 (14/09/2019) + +#### Enhancements: + +- React Native 0.60 Support [#375](https://github.com/wix/react-native-notifications/pull/375) +- New api changes ios [#342](https://github.com/wix/react-native-notifications/pull/342) + +--- + +## v1.4.0 (18/04/2019) +*No changelog for this release.* + +--- + +## v1.1.17 (26/10/2017) +*No changelog for this release.* + +--- + +## v1.1.12 (13/07/2017) +*No changelog for this release.* diff --git a/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java index f527a5d..f9c858b 100644 --- a/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +++ b/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java @@ -2,7 +2,7 @@ package com.wix.reactnativenotifications; import android.content.Context; -import android.support.annotation.Nullable; +import android.support.annotation.NonNull; import android.support.v4.app.NotificationManagerCompat; public abstract class NotificationManagerCompatFacade { diff --git a/example/android/build.gradle b/example/android/build.gradle index 194ad63..77dc62d 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -16,7 +16,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.3.1' - classpath 'com.google.gms:google-services:4.0.0' + classpath 'com.google.gms:google-services:4.0.1' } } diff --git a/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj b/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj index d3b1070..271a210 100644 --- a/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj +++ b/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 50CBD3CD22F2558C00142352 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 50CBD3A922F2556900142352 /* libRCTAnimation.a */; }; + 5004AC02233BE75A00490132 /* CallKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5004ABE1233BE75A00490132 /* CallKit.framework */; }; 50F1F0CC22CE3B4700FD5829 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F1F06022CE3A6100FD5829 /* libReact.a */; }; 50F1F0CD22CE3B6300FD5829 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F1F08A22CE3AA000FD5829 /* libRCTActionSheet.a */; }; 50F1F0CF22CE3B6300FD5829 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F1F09522CE3ABE00FD5829 /* libRCTImage.a */; }; @@ -259,20 +259,6 @@ remoteGlobalIDString = 2D2A28881D9B049200D4039D; remoteInfo = "RCTWebSocket-tvOS"; }; - 50F1F0C822CE3B2E00FD5829 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3DBE0D001F3B181A0099AA32; - remoteInfo = fishhook; - }; - 50F1F0CA22CE3B2E00FD5829 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3DBE0D0D1F3B181C0099AA32; - remoteInfo = "fishhook-tvOS"; - }; D85498D01D97B31100DEEE06 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = D85498C21D97B31100DEEE06 /* RNNotifications.xcodeproj */; @@ -298,7 +284,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = NotificationsExampleApp/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = NotificationsExampleApp/main.m; sourceTree = ""; }; 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; - 50CBD3A222F2556900142352 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; + 5004ABE1233BE75A00490132 /* CallKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CallKit.framework; path = System/Library/Frameworks/CallKit.framework; sourceTree = SDKROOT; }; 50F1F08522CE3A9F00FD5829 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; 50F1F0A022CE3B0600FD5829 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; @@ -322,6 +308,7 @@ 50F1F0D222CE3B6300FD5829 /* libRCTSettings.a in Frameworks */, 50F1F0D322CE3B6300FD5829 /* libRCTText.a in Frameworks */, 50F1F0D422CE3B6300FD5829 /* libRCTVibration.a in Frameworks */, + 5004AC02233BE75A00490132 /* CallKit.framework in Frameworks */, 50F1F0D522CE3B6300FD5829 /* libRCTWebSocket.a in Frameworks */, 50F1F0CC22CE3B4700FD5829 /* libReact.a in Frameworks */, D84861182267695100E9103D /* JavaScriptCore.framework in Frameworks */, @@ -461,8 +448,6 @@ children = ( 50F1F0C522CE3B2E00FD5829 /* libRCTWebSocket.a */, 50F1F0C722CE3B2E00FD5829 /* libRCTWebSocket-tvOS.a */, - 50F1F0C922CE3B2E00FD5829 /* libfishhook.a */, - 50F1F0CB22CE3B2E00FD5829 /* libfishhook-tvOS.a */, ); name = Products; sourceTree = ""; @@ -509,6 +494,7 @@ D84860E82267695100E9103D /* Frameworks */ = { isa = PBXGroup; children = ( + 5004ABE1233BE75A00490132 /* CallKit.framework */, D84861172267695100E9103D /* JavaScriptCore.framework */, ); name = Frameworks; @@ -558,6 +544,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -849,20 +836,6 @@ remoteRef = 50F1F0C622CE3B2E00FD5829 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 50F1F0C922CE3B2E00FD5829 /* libfishhook.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libfishhook.a; - remoteRef = 50F1F0C822CE3B2E00FD5829 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 50F1F0CB22CE3B2E00FD5829 /* libfishhook-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libfishhook-tvOS.a"; - remoteRef = 50F1F0CA22CE3B2E00FD5829 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; D85498D11D97B31100DEEE06 /* libRNNotifications.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; diff --git a/lib/android/app/src/main/AndroidManifest.xml b/lib/android/app/src/main/AndroidManifest.xml index b6dad7c..1ae59f8 100644 --- a/lib/android/app/src/main/AndroidManifest.xml +++ b/lib/android/app/src/main/AndroidManifest.xml @@ -12,7 +12,7 @@ - + diff --git a/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 91fd8cc..524ff07 100644 --- a/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -23,7 +23,7 @@ import com.wix.reactnativenotifications.core.ProxyService; import static com.wix.reactnativenotifications.Defs.NOTIFICATION_OPENED_EVENT_NAME; import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_EVENT_NAME; - +import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_FOREGROUND_EVENT_NAME; public class PushNotification implements IPushNotification { @@ -64,6 +64,9 @@ public class PushNotification implements IPushNotification { public void onReceived() throws InvalidNotificationException { postNotification(null); notifyReceivedToJS(); + if (mAppLifecycleFacade.isAppVisible()) { + notifiyReceivedForegroundNotificationToJS(); + } } @Override @@ -148,11 +151,18 @@ public class PushNotification implements IPushNotification { final Notification.Builder notification = new Notification.Builder(mContext) .setContentTitle(mNotificationProps.getTitle()) .setContentText(mNotificationProps.getBody()) - .setSmallIcon(mContext.getApplicationInfo().icon) .setContentIntent(intent) .setDefaults(Notification.DEFAULT_ALL) .setAutoCancel(true); + + int resourceID = mContext.getResources().getIdentifier("notification_icon", "drawable", mContext.getPackageName()); + if (resourceID != 0) { + notification.setSmallIcon(resourceID); + } else { + notification.setSmallIcon(mContext.getApplicationInfo().icon); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, @@ -189,6 +199,10 @@ public class PushNotification implements IPushNotification { mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext()); } + private void notifiyReceivedForegroundNotificationToJS() { + mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_FOREGROUND_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext()); + } + private void notifyOpenedToJS() { mJsIOHelper.sendEventToJS(NOTIFICATION_OPENED_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext()); } diff --git a/package.json b/package.json index b5c6286..c18edc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "2.1.0", + "version": "2.1.3", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", @@ -38,7 +38,8 @@ "test-js": "node ./scripts/test-js", "xcode": "open example/ios/NotificationsExampleApp.xcodeproj", "androidStudio": "open -a /Applications/Android\\ Studio.app ./example/android", - "release": "node ./scripts/release" + "release": "node ./scripts/release", + "generate-changelog": "gren changelog" }, "nativePackage": true, "peerDependencies": { @@ -61,7 +62,7 @@ "shell-utils": "1.x.x", "react-native": "0.60.5", "react": "16.8.6", - "detox": "13.x.x", + "detox": "14.x.x", "jsc-android": "236355.x.x", "jest": "24.8.0", "metro-react-native-babel-preset": "0.55.x", @@ -86,7 +87,7 @@ "ios.none": { "binaryPath": "playground/ios/DerivedData/playground/Build/Products/Debug-iphonesimulator/playground.app", "type": "ios.none", - "name": "iPhone X", + "name": "iPhone 11", "session": { "server": "ws://localhost:8099", "sessionId": "playground" @@ -96,13 +97,13 @@ "binaryPath": "example/ios/DerivedData/NotificationsExampleApp/Build/Products/Debug-iphonesimulator/NotificationsExampleApp.app", "build": "RCT_NO_LAUNCH_PACKAGER=true xcodebuild build -scheme NotificationsExampleApp -project example/ios/NotificationsExampleApp.xcodeproj -sdk iphonesimulator -configuration Debug -derivedDataPath example/ios/DerivedData/NotificationsExampleApp ONLY_ACTIVE_ARCH=YES -quiet -UseModernBuildSystem=NO", "type": "ios.simulator", - "name": "iPhone X" + "name": "iPhone 11" }, "ios.sim.release": { "binaryPath": "example/ios/DerivedData/NotificationsExampleApp/Build/Products/Release-iphonesimulator/NotificationsExampleApp.app", "build": "RCT_NO_LAUNCH_PACKAGER=true xcodebuild build -scheme NotificationsExampleApp_release -project example/ios/NotificationsExampleApp.xcodeproj -sdk iphonesimulator -configuration Release -derivedDataPath example/ios/DerivedData/NotificationsExampleApp ONLY_ACTIVE_ARCH=YES -quiet -UseModernBuildSystem=NO", "type": "ios.simulator", - "name": "iPhone X" + "name": "iPhone 11" } } }, @@ -138,4 +139,4 @@ "html" ] } -} \ No newline at end of file +} diff --git a/scripts/release.js b/scripts/release.js index 3d3067c..3f26bc4 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -131,8 +131,8 @@ function updatePackageJson(version) { } function generateChangelog() { - exec.execSync('gren changelog'); - exec.execSync(`git add ${grenrc.changelogFileName}`); + exec.execSync('npm run generate-changelog'); + exec.execSync(`git add ${grenrc.changelogFilename}`); } run(); diff --git a/scripts/test-unit.js b/scripts/test-unit.js index 9ba2c40..826de25 100644 --- a/scripts/test-unit.js +++ b/scripts/test-unit.js @@ -44,7 +44,7 @@ function runIosUnitTests() { -project NotificationsExampleApp.xcodeproj -sdk iphonesimulator -configuration ${conf} - -destination 'platform=iOS Simulator,name=iPhone X' + -destination 'platform=iOS Simulator,name=iPhone 11' -derivedDataPath ./example/ios/DerivedData/NotificationsExampleApp ONLY_ACTIVE_ARCH=YES`); } -- 2.26.2