Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 57 additions & 26 deletions CHANGELOG.gren.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void callOnOpenedIfNeed(Activity activity) {
Intent intent = activity.getIntent();
if (NotificationIntentAdapter.canHandleIntent(intent)) {
Context appContext = mApplication.getApplicationContext();
Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
Bundle notificationData = intent.getExtras();
final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
if (pushNotification != null) {
pushNotification.onOpened();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ public class NotificationIntentAdapter {

@SuppressLint("UnspecifiedImmutableFlag")
public static PendingIntent createPendingNotificationIntent(Context appContext, PushNotificationProps notification) {
if (canHandleTrampolineActivity(appContext)) {
Intent intent = new Intent(appContext, ProxyService.class);
intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
return PendingIntent.getService(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT);
} else {
Intent mainActivityIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
mainActivityIntent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(appContext);
taskStackBuilder.addNextIntentWithParentStack(mainActivityIntent);
return taskStackBuilder.getPendingIntent((int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
}
// Fix local notification press reloading the app
// https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/4585/commits/153fe2a9fe46a46e0c8dbda1afc6f8b5ff1d60e6
Intent intent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
return PendingIntent.getActivity(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
}

public static boolean canHandleTrampolineActivity(Context appContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ public synchronized boolean isReactInitialized() {
return false;
}

try {
return mReactContext.hasActiveCatalystInstance();
} catch (Exception e) {
return mReactContext.hasActiveReactInstance();
}
return mReactContext.hasActiveReactInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public void onAppVisible() {
public void onAppNotVisible() {
}
};
final private String DEFAULT_CHANNEL_ID = "channel_01";
final private String DEFAULT_CHANNEL_NAME = "Channel Name";
final private String DEFAULT_CHANNEL_ID = "exodus";
final private String DEFAULT_CHANNEL_NAME = "Exodus Default";

public static IPushNotification get(Context context, Bundle bundle) {
Context appContext = context.getApplicationContext();
Expand Down Expand Up @@ -118,6 +118,18 @@ protected void digestNotification() {
}

protected PushNotificationProps createProps(Bundle bundle) {
if (bundle != null) {
// pinpoint UI message sending compatibility
if (!bundle.containsKey("body") && bundle.containsKey("pinpoint.notification.body")) {
bundle.putString("body", bundle.getString("pinpoint.notification.body"));
}
if (!bundle.containsKey("title") && bundle.containsKey("pinpoint.notification.title")) {
bundle.putString("title", bundle.getString("pinpoint.notification.title"));
}
if (!bundle.containsKey("url") && bundle.containsKey("pinpoint.deeplink")) {
bundle.putString("url", bundle.getString("pinpoint.deeplink"));
}
}
return new PushNotificationProps(bundle);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,19 @@ protected void refreshToken() {
}

protected void sendTokenToJS() {
final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager();
final ReactContext reactContext = instanceManager.getCurrentReactContext();

ReactContext reactContext;
if (com.facebook.react.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
reactContext = ((ReactApplication) mAppContext).getReactHost().getCurrentReactContext();
} else {
final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager();
reactContext = instanceManager.getCurrentReactContext();
}
// Note: Cannot assume react-context exists cause this is an async dispatched service.
if (reactContext != null && reactContext.hasActiveCatalystInstance()) {
if (reactContext != null && reactContext.hasActiveReactInstance()) {
Bundle tokenMap = new Bundle();
tokenMap.putString("deviceToken", sToken);
mJsIOHelper.sendEventToJS(TOKEN_RECEIVED_EVENT_NAME, tokenMap, reactContext);
}
}

}
4 changes: 2 additions & 2 deletions lib/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
mavenLocal()
mavenCentral()
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:$androidGradlePluginVersion"
Expand All @@ -27,7 +27,7 @@ allprojects {
mavenLocal()
mavenCentral()
google()
jcenter()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../../node_modules/react-native/android"
Expand Down
6 changes: 5 additions & 1 deletion lib/ios/RNCommandsHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ - (void)setCategories:(NSArray *)categories {
}

- (void)getInitialNotification:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
NSDictionary* initialNotification = [[RNNotificationsStore sharedInstance] initialNotification];
NSDictionary* initialNotification;
if([[RNNotificationsStore sharedInstance] notificationTapped]){
[[RNNotificationsStore sharedInstance] setNotificationTapped:NO];
initialNotification = [[RNNotificationsStore sharedInstance] initialNotification];
}
[[RNNotificationsStore sharedInstance] setInitialNotification:nil];
resolve(initialNotification);
}
Expand Down
1 change: 1 addition & 0 deletions lib/ios/RNNotificationEventHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ - (void)didReceiveForegroundNotification:(UNNotification *)notification withComp

- (void)didReceiveNotificationResponse:(UNNotificationResponse *)response completionHandler:(void (^)(void))completionHandler {
[_store setActionCompletionHandler:completionHandler withCompletionKey:response.notification.request.identifier];
[_store setNotificationTapped:true];
[RNEventEmitter sendEvent:RNNotificationOpened body:[RNNotificationParser parseNotificationResponse:response]];
}

Expand Down
1 change: 1 addition & 0 deletions lib/ios/RNNotificationsStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@interface RNNotificationsStore : NSObject

@property (nonatomic, retain) NSDictionary* initialNotification;
@property BOOL notificationTapped;

+ (instancetype)sharedInstance;

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-notifications",
"version": "5.0.0",
"name": "@exodus/react-native-notifications",
"version": "5.1.0-exodus.1",
"description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android",
"license": "MIT",
"keywords": [
Expand Down Expand Up @@ -76,11 +76,11 @@
},
"repository": {
"type": "git",
"url": "https://github.com/wix/react-native-notifications.git"
"url": "https://github.com/ExodusForks/react-native-notifications.git"
},
"homepage": "https://github.com/wix/react-native-notifications",
"homepage": "https://github.com/ExodusForks/react-native-notifications",
"bugs": {
"url": "https://github.com/wix/react-native-notifications/issues"
"url": "https://github.com/ExodusForks/react-native-notifications/issues"
},
"jest": {
"preset": "react-native",
Expand Down
Loading