Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielEliraz committed Jul 20, 2023
2 parents 1b88351 + 1e51492 commit aa3e149
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 286 deletions.
439 changes: 176 additions & 263 deletions CHANGELOG.gren.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ private void callOnOpenedIfNeed(Activity activity) {
Intent intent = activity.getIntent();
if (NotificationIntentAdapter.canHandleIntent(intent)) {
Context appContext = mApplication.getApplicationContext();
Bundle notificationData = NotificationIntentAdapter.canHandleTrampolineActivity(appContext) ?
intent.getExtras() : NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
if (pushNotification != null) {
pushNotification.onOpened();
// Erase notification intent after using it, to avoid looping with the same notification
// in case the app is moved to background and opened again
activity.setIntent(new Intent());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public static boolean canHandleTrampolineActivity(Context appContext) {
}

public static Bundle extractPendingNotificationDataFromIntent(Intent intent) {
return intent.getBundleExtra(PUSH_NOTIFICATION_EXTRA_NAME);
Bundle notificationBundle = intent.getBundleExtra(PUSH_NOTIFICATION_EXTRA_NAME);
if (notificationBundle != null) {
return notificationBundle;
} else {
return intent.getExtras();
}
}

public static boolean canHandleIntent(Intent intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import com.facebook.react.bridge.ReactContext;
import com.wix.reactnativenotifications.core.AppLaunchHelper;
Expand All @@ -21,6 +22,7 @@
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_BACKGROUND_EVENT_NAME;
import static com.wix.reactnativenotifications.Defs.LOGTAG;

public class PushNotification implements IPushNotification {

Expand Down Expand Up @@ -198,18 +200,32 @@ protected int createNotificationId(Notification notification) {
}

private void notifyReceivedToJS() {
mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext());
try {
Bundle bundle = mNotificationProps.asBundle();
mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_EVENT_NAME, bundle, mAppLifecycleFacade.getRunningReactContext());
} catch (NullPointerException ex) {
Log.e(LOGTAG, "notifyReceivedToJS: Null pointer exception");
}
}

private void notifyReceivedBackgroundToJS() {
mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_BACKGROUND_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext());
try {
Bundle bundle = mNotificationProps.asBundle();
mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_BACKGROUND_EVENT_NAME, bundle, mAppLifecycleFacade.getRunningReactContext());
} catch (NullPointerException ex) {
Log.e(LOGTAG, "notifyReceivedBackgroundToJS: Null pointer exception");
}
}

private void notifyOpenedToJS() {
Bundle response = new Bundle();
response.putBundle("notification", mNotificationProps.asBundle());

mJsIOHelper.sendEventToJS(NOTIFICATION_OPENED_EVENT_NAME, response, mAppLifecycleFacade.getRunningReactContext());
try {
response.putBundle("notification", mNotificationProps.asBundle());
mJsIOHelper.sendEventToJS(NOTIFICATION_OPENED_EVENT_NAME, response, mAppLifecycleFacade.getRunningReactContext());
} catch (NullPointerException ex) {
Log.e(LOGTAG, "notifyOpenedToJS: Null pointer exception");
}
}

protected void launchOrResumeApp() {
Expand Down
2 changes: 1 addition & 1 deletion lib/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
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-notifications",
"version": "4.3.4-0",
"version": "5.0.0",
"description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android",
"license": "MIT",
"keywords": [
Expand Down
1 change: 0 additions & 1 deletion react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
packageInstance: 'new RNNotificationsPackage(reactNativeHost.getApplication())',
}
},
assets: []
},
project: {
ios: {
Expand Down
24 changes: 12 additions & 12 deletions scripts/test-unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,38 @@ function run() {

function runAndroidUnitTests() {
const conf = release ? 'testReactNative60ReleaseUnitTest' : 'testReactNative60DebugUnitTest';
if (android && process.env.JENKINS_CI) {
const sdkmanager = '/usr/local/share/android-sdk/tools/bin/sdkmanager';
exec.execSync(`yes | ${sdkmanager} --licenses`);
// exec.execSync(`echo y | ${sdkmanager} --update && echo y | ${sdkmanager} --licenses`);
}
exec.execSync(`cd lib/android && ./gradlew ${conf}`);
}

function runIosUnitTests() {
const conf = release ? `Release` : `Debug`;
exec.execSync('npm run build');
exec.execSync('npm run pod-install');
testTarget('NotificationsExampleApp', 'iPhone 12', '14.4');
}

function testTarget(scheme, device, OS = 'latest') {
const conf = release ? `Release` : `Debug`;
exec.execSync(`cd ./example/ios &&
RCT_NO_LAUNCH_PACKAGER=true
xcodebuild build build-for-testing
-scheme "NotificationsExampleApp"
-scheme "${scheme}"
-workspace NotificationsExampleApp.xcworkspace
-sdk iphonesimulator
-configuration ${conf}
-derivedDataPath ./example/ios/DerivedData/NotificationsExampleApp
-derivedDataPath ./DerivedData/NotificationsExampleApp
-quiet
-UseModernBuildSystem=NO
-UseModernBuildSystem=YES
ONLY_ACTIVE_ARCH=YES`);

exec.execSync(`cd ./example/ios &&
RCT_NO_LAUNCH_PACKAGER=true
xcodebuild test-without-building
-scheme "NotificationsExampleApp"
-scheme "${scheme}"
-workspace NotificationsExampleApp.xcworkspace
-sdk iphonesimulator
-configuration ${conf}
-destination 'platform=iOS Simulator,name=iPhone 11'
-derivedDataPath ./example/ios/DerivedData/NotificationsExampleApp
-destination 'platform=iOS Simulator,name=${device},OS=${OS}'
-derivedDataPath ./DerivedData/NotificationsExampleApp
ONLY_ACTIVE_ARCH=YES`);
}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/docs/localNotifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let localNotification = Notifications.postLocalNotification({

Notification object contains:

- **`fireDate`**- The date and time when the system should deliver the notification (optinal - default is immediate dispatch).
- **`fireDate`**- The date and time when the system should deliver the notification (optional - default is immediate dispatch).
- `body`- The message displayed in the notification alert.
- `title`- The title of the notification, displayed in the notifications center.
- `alertAction`- The "action" displayed beneath an actionable notification on the lockscreen (e.g. "Slide to **open**"). Note that Apple no longer shows this in iOS 10.
Expand Down

0 comments on commit aa3e149

Please sign in to comment.