Chore: Upgrade react-native-notifications to 4.2.4 (#3958)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
cd0c8abced
commit
5494037f78
|
@ -277,14 +277,14 @@ android {
|
|||
dependencies {
|
||||
addUnimodulesDependencies()
|
||||
implementation project(':@react-native-community_viewpager')
|
||||
playImplementation project(':reactnativenotifications')
|
||||
playImplementation project(':react-native-notifications')
|
||||
playImplementation 'com.google.firebase:firebase-core:16.0.0'
|
||||
playImplementation project(':@react-native-firebase_app')
|
||||
playImplementation project(':@react-native-firebase_analytics')
|
||||
playImplementation project(':@react-native-firebase_crashlytics')
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
//noinspection GradleDynamicVersion
|
||||
implementation "com.facebook.react:react-native:+" // From node_modules
|
||||
playImplementation "com.google.firebase:firebase-messaging:18.0.0"
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
|
||||
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
|
||||
exclude group:'com.facebook.fbjni'
|
||||
|
|
|
@ -3,7 +3,6 @@ package chat.rocket.reactnative;
|
|||
import android.app.Application;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.wix.reactnativenotifications.RNNotificationsPackage;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -17,8 +16,7 @@ public class AdditionalModules {
|
|||
return Arrays.<ReactPackage>asList(
|
||||
new ReactNativeFirebaseAnalyticsPackage(),
|
||||
new ReactNativeFirebaseAppPackage(),
|
||||
new ReactNativeFirebaseCrashlyticsPackage(),
|
||||
new RNNotificationsPackage(application)
|
||||
new ReactNativeFirebaseCrashlyticsPackage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ apply from: '../node_modules/react-native-unimodules/gradle.groovy'
|
|||
includeUnimodulesProjects()
|
||||
|
||||
rootProject.name = 'RocketChatRN'
|
||||
include ':reactnativenotifications'
|
||||
project(':reactnativenotifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android/app')
|
||||
include ':@react-native-community_viewpager'
|
||||
project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android')
|
||||
include ':@react-native-firebase_app'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export interface INotification {
|
||||
payload: {
|
||||
message: string;
|
||||
style: string;
|
||||
ejson: string;
|
||||
|
@ -9,5 +10,6 @@ export interface INotification {
|
|||
from: string;
|
||||
image: string;
|
||||
soundname: string;
|
||||
getData: () => INotification;
|
||||
};
|
||||
identifier: string;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ interface IEjson {
|
|||
}
|
||||
|
||||
export const onNotification = (push: INotification): void => {
|
||||
if (push) {
|
||||
if (push.payload) {
|
||||
try {
|
||||
const notification = push?.getData();
|
||||
const notification = push.payload;
|
||||
const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson);
|
||||
|
||||
const types: Record<string, string> = {
|
||||
|
@ -40,7 +40,6 @@ export const onNotification = (push: INotification): void => {
|
|||
path: `${types[type]}/${roomName}`,
|
||||
isCall: messageType === 'jitsi_call_started'
|
||||
};
|
||||
// TODO REDUX MIGRATION TO TS
|
||||
store.dispatch(deepLinkingOpen(params));
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
// @ts-ignore
|
||||
// TODO BUMP LIB VERSION
|
||||
import NotificationsIOS, { NotificationAction, NotificationCategory, Notification } from 'react-native-notifications';
|
||||
|
||||
import { store as reduxStore } from '../../lib/store/auxStore';
|
||||
import I18n from '../../i18n';
|
||||
import { INotification } from '../../definitions/INotification';
|
||||
|
||||
class PushNotification {
|
||||
onNotification: (notification: Notification) => void;
|
||||
deviceToken: string;
|
||||
|
||||
constructor() {
|
||||
this.onNotification = () => {};
|
||||
this.deviceToken = '';
|
||||
|
||||
NotificationsIOS.addEventListener('remoteNotificationsRegistered', (deviceToken: string) => {
|
||||
this.deviceToken = deviceToken;
|
||||
});
|
||||
|
||||
NotificationsIOS.addEventListener('notificationOpened', (notification: Notification, completion: () => void) => {
|
||||
// TODO REDUX MIGRATION TO TS
|
||||
const { background } = reduxStore.getState().app;
|
||||
if (background) {
|
||||
this.onNotification(notification);
|
||||
}
|
||||
completion();
|
||||
});
|
||||
|
||||
const actions = [
|
||||
new NotificationCategory({
|
||||
identifier: 'MESSAGE',
|
||||
actions: [
|
||||
new NotificationAction({
|
||||
activationMode: 'background',
|
||||
title: I18n.t('Reply'),
|
||||
textInput: {
|
||||
buttonTitle: I18n.t('Reply'),
|
||||
placeholder: I18n.t('Type_message')
|
||||
},
|
||||
identifier: 'REPLY_ACTION'
|
||||
})
|
||||
]
|
||||
})
|
||||
];
|
||||
NotificationsIOS.requestPermissions(actions);
|
||||
}
|
||||
|
||||
getDeviceToken() {
|
||||
return this.deviceToken;
|
||||
}
|
||||
|
||||
setBadgeCount = (count = 0) => {
|
||||
NotificationsIOS.setBadgesCount(count);
|
||||
};
|
||||
|
||||
async configure(onNotification: (notification: INotification) => void) {
|
||||
this.onNotification = onNotification;
|
||||
const initial = await NotificationsIOS.getInitialNotification();
|
||||
return Promise.resolve(initial);
|
||||
}
|
||||
}
|
||||
export default new PushNotification();
|
|
@ -1,35 +1,87 @@
|
|||
// @ts-ignore
|
||||
// TODO BUMP LIB VERSION
|
||||
import { NotificationsAndroid, PendingNotifications, Notification } from 'react-native-notifications';
|
||||
import {
|
||||
Notifications,
|
||||
Registered,
|
||||
RegistrationError,
|
||||
NotificationCompletion,
|
||||
Notification,
|
||||
NotificationAction,
|
||||
NotificationCategory
|
||||
} from 'react-native-notifications';
|
||||
|
||||
import { INotification } from '../../definitions/INotification';
|
||||
import { isIOS } from '../../utils/deviceInfo';
|
||||
import { store as reduxStore } from '../../lib/store/auxStore';
|
||||
import I18n from '../../i18n';
|
||||
|
||||
class PushNotification {
|
||||
onNotification: (notification: Notification) => void;
|
||||
onNotification: (notification: any) => void;
|
||||
deviceToken: string;
|
||||
constructor() {
|
||||
this.onNotification = () => {};
|
||||
this.deviceToken = '';
|
||||
if (isIOS) {
|
||||
// init
|
||||
Notifications.ios.registerRemoteNotifications();
|
||||
|
||||
NotificationsAndroid.setRegistrationTokenUpdateListener((deviceToken: string) => {
|
||||
this.deviceToken = deviceToken;
|
||||
// setCategories
|
||||
const notificationAction = new NotificationAction('REPLY_ACTION', 'background', I18n.t('Reply'), true, {
|
||||
buttonTitle: I18n.t('Reply'),
|
||||
placeholder: I18n.t('Type_message')
|
||||
});
|
||||
const notificationCategory = new NotificationCategory('MESSAGE', [notificationAction]);
|
||||
Notifications.setCategories([notificationCategory]);
|
||||
} else {
|
||||
// init
|
||||
Notifications.android.registerRemoteNotifications();
|
||||
}
|
||||
|
||||
Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => {
|
||||
this.deviceToken = event.deviceToken;
|
||||
});
|
||||
|
||||
NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => {
|
||||
Notifications.events().registerRemoteNotificationsRegistrationFailed((event: RegistrationError) => {
|
||||
// TODO: Handle error
|
||||
console.log(event);
|
||||
});
|
||||
|
||||
Notifications.events().registerNotificationReceivedForeground(
|
||||
(notification: Notification, completion: (response: NotificationCompletion) => void) => {
|
||||
completion({ alert: true, sound: true, badge: false });
|
||||
}
|
||||
);
|
||||
|
||||
Notifications.events().registerNotificationOpened((notification: Notification, completion: () => void) => {
|
||||
if (isIOS) {
|
||||
const { background } = reduxStore.getState().app;
|
||||
if (background) {
|
||||
this.onNotification(notification);
|
||||
}
|
||||
} else {
|
||||
this.onNotification(notification);
|
||||
}
|
||||
completion();
|
||||
});
|
||||
|
||||
Notifications.events().registerNotificationReceivedBackground(
|
||||
(notification: Notification, completion: (response: any) => void) => {
|
||||
completion({ alert: true, sound: true, badge: false });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getDeviceToken() {
|
||||
return this.deviceToken;
|
||||
}
|
||||
|
||||
setBadgeCount = (_?: number) => {};
|
||||
setBadgeCount = (count?: number) => {
|
||||
if (isIOS && count) {
|
||||
Notifications.ios.setBadgeCount(count);
|
||||
}
|
||||
};
|
||||
|
||||
configure(onNotification: (notification: INotification) => void) {
|
||||
configure(onNotification: (notification: INotification) => void): Promise<any> {
|
||||
this.onNotification = onNotification;
|
||||
NotificationsAndroid.refreshToken();
|
||||
return PendingNotifications.getInitialNotification();
|
||||
return Notifications.getInitialNotification();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -415,8 +415,8 @@ PODS:
|
|||
- React-Core
|
||||
- react-native-netinfo (6.0.0):
|
||||
- React-Core
|
||||
- react-native-notifications (2.1.7):
|
||||
- React
|
||||
- react-native-notifications (4.2.4):
|
||||
- React-Core
|
||||
- react-native-orientation-locker (1.1.8):
|
||||
- React
|
||||
- react-native-restart (0.0.22):
|
||||
|
@ -1004,7 +1004,7 @@ SPEC CHECKSUMS:
|
|||
react-native-jitsi-meet: 3e3ac5d0445091154119f94342efd55c8b1124ce
|
||||
react-native-mmkv-storage: 88bcb10bbe85a8122061d17d03abcc64a02fe1c9
|
||||
react-native-netinfo: e849fc21ca2f4128a5726c801a82fc6f4a6db50d
|
||||
react-native-notifications: ee8fd739853e72694f3af8b374c8ccb106b7b227
|
||||
react-native-notifications: 3de8ef9cd800e5db0225d9aa46b228d2b94ce51e
|
||||
react-native-orientation-locker: f0ca1a8e5031dab6b74bfb4ab33a17ed2c2fcb0d
|
||||
react-native-restart: 733a51ad137f15b0f8dc34c4082e55af7da00979
|
||||
react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
"react-native-mmkv-storage": "0.6.12",
|
||||
"react-native-modal": "11.10.0",
|
||||
"react-native-navigation-bar-color": "2.0.1",
|
||||
"react-native-notifications": "2.1.7",
|
||||
"react-native-notifications": "^4.2.4",
|
||||
"react-native-notifier": "1.6.1",
|
||||
"react-native-orientation-locker": "1.1.8",
|
||||
"react-native-picker-select": "^8.0.4",
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
diff --git a/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
|
||||
index 524ff07..70f22d5 100644
|
||||
--- a/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
|
||||
+++ b/node_modules/react-native-notifications/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
|
||||
@@ -31,7 +31,7 @@ public class PushNotification implements IPushNotification {
|
||||
final protected AppLifecycleFacade mAppLifecycleFacade;
|
||||
final protected AppLaunchHelper mAppLaunchHelper;
|
||||
final protected JsIOHelper mJsIOHelper;
|
||||
- final protected PushNotificationProps mNotificationProps;
|
||||
+ protected PushNotificationProps mNotificationProps;
|
||||
final protected AppVisibilityListener mAppVisibilityListener = new AppVisibilityListener() {
|
||||
@Override
|
||||
public void onAppVisible() {
|
||||
diff --git a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
index f9c858b..94ea188 100644
|
||||
--- a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
+++ b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
@@ -2,8 +2,8 @@
|
||||
package com.wix.reactnativenotifications;
|
||||
|
||||
import android.content.Context;
|
||||
-import android.support.annotation.NonNull;
|
||||
-import android.support.v4.app.NotificationManagerCompat;
|
||||
+import androidx.annotation.NonNull;
|
||||
+import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
public abstract class NotificationManagerCompatFacade {
|
||||
public static NotificationManagerCompat from(@NonNull Context context) {
|
|
@ -0,0 +1,79 @@
|
|||
diff --git a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
index f9c858b..94ea188 100644
|
||||
--- a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
+++ b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
@@ -2,8 +2,8 @@
|
||||
package com.wix.reactnativenotifications;
|
||||
|
||||
import android.content.Context;
|
||||
-import android.support.annotation.NonNull;
|
||||
-import android.support.v4.app.NotificationManagerCompat;
|
||||
+import androidx.annotation.NonNull;
|
||||
+import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
public abstract class NotificationManagerCompatFacade {
|
||||
public static NotificationManagerCompat from(@NonNull Context context) {
|
||||
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
|
||||
index b93f762..c2b736a 100644
|
||||
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
|
||||
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
|
||||
@@ -28,7 +28,7 @@ public class PushNotification implements IPushNotification {
|
||||
final protected AppLifecycleFacade mAppLifecycleFacade;
|
||||
final protected AppLaunchHelper mAppLaunchHelper;
|
||||
final protected JsIOHelper mJsIOHelper;
|
||||
- final protected PushNotificationProps mNotificationProps;
|
||||
+ protected PushNotificationProps mNotificationProps;
|
||||
final protected AppVisibilityListener mAppVisibilityListener = new AppVisibilityListener() {
|
||||
@Override
|
||||
public void onAppVisible() {
|
||||
diff --git a/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
index f9c858b..94ea188 100644
|
||||
--- a/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
+++ b/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java
|
||||
@@ -2,8 +2,8 @@
|
||||
package com.wix.reactnativenotifications;
|
||||
|
||||
import android.content.Context;
|
||||
-import android.support.annotation.NonNull;
|
||||
-import android.support.v4.app.NotificationManagerCompat;
|
||||
+import androidx.annotation.NonNull;
|
||||
+import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
public abstract class NotificationManagerCompatFacade {
|
||||
public static NotificationManagerCompat from(@NonNull Context context) {
|
||||
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
|
||||
index 4b33656..36aaa47 100644
|
||||
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
|
||||
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
|
||||
@@ -29,18 +29,20 @@ - (void)requestPermissions:(NSDictionary *)options {
|
||||
authOptions = authOptions | UNAuthorizationOptionAnnouncement;
|
||||
}
|
||||
}
|
||||
+ if(![[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"]){
|
||||
+ [UNUserNotificationCenter.currentNotificationCenter requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
|
||||
+ if (!error && granted) {
|
||||
+ [UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
||||
+ if (settings.authorizationStatus == UNAuthorizationStatusAuthorized || settings.authorizationStatus == UNAuthorizationStatusProvisional) {
|
||||
+ dispatch_async(dispatch_get_main_queue(), ^{
|
||||
+ [[UIApplication sharedApplication] registerForRemoteNotifications];
|
||||
+ });
|
||||
+ }
|
||||
+ }];
|
||||
+ }
|
||||
+ }];
|
||||
+ }
|
||||
|
||||
- [UNUserNotificationCenter.currentNotificationCenter requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
|
||||
- if (!error && granted) {
|
||||
- [UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
||||
- if (settings.authorizationStatus == UNAuthorizationStatusAuthorized || settings.authorizationStatus == UNAuthorizationStatusProvisional) {
|
||||
- dispatch_async(dispatch_get_main_queue(), ^{
|
||||
- [[UIApplication sharedApplication] registerForRemoteNotifications];
|
||||
- });
|
||||
- }
|
||||
- }];
|
||||
- }
|
||||
- }];
|
||||
}
|
||||
|
||||
- (void)setCategories:(NSArray *)json {
|
|
@ -1,10 +1,5 @@
|
|||
module.exports = {
|
||||
dependencies: {
|
||||
'react-native-notifications': {
|
||||
platforms: {
|
||||
android: null
|
||||
}
|
||||
},
|
||||
'@react-native-firebase/app': {
|
||||
platforms: {
|
||||
android: null
|
||||
|
|
16
yarn.lock
16
yarn.lock
|
@ -14836,13 +14836,10 @@ react-native-navigation-bar-color@2.0.1:
|
|||
resolved "https://registry.yarnpkg.com/react-native-navigation-bar-color/-/react-native-navigation-bar-color-2.0.1.tgz#ee2be25cc37105f7da355717b0a9a32c9c059ae6"
|
||||
integrity sha512-1kE/oxWt+HYjRxdZdvke9tJ365xaee5n3+euOQA1En8zQuSbOxiE4SYEGM7TeaWnmLJ0l37mRnPHaB2H4mGh0A==
|
||||
|
||||
react-native-notifications@2.1.7:
|
||||
version "2.1.7"
|
||||
resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-2.1.7.tgz#ef836f6f8c12bdc5103598035590347811426a70"
|
||||
integrity sha512-m9jfpobP1BpqG2w6pN2kKzKJt2bqrLIRS3QAuH0MU0dpRwib/4ehaAUKOiFj+xVCtuKHALpceb97FHuA0i4dkw==
|
||||
dependencies:
|
||||
core-js "^1.0.0"
|
||||
uuid "^2.0.3"
|
||||
react-native-notifications@^4.2.4:
|
||||
version "4.2.4"
|
||||
resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-4.2.4.tgz#0d686eb1576d3d9cb73dd9db1ee4f212e00f7d89"
|
||||
integrity sha512-ffToxERa2bRUsXShCO19yXY6c6l4Esq7MqRKAb4mPSn+T428X7Je7WYvWOIOVw/BMGJ3R0lPrZk52vDpoYqanw==
|
||||
|
||||
react-native-notifier@1.6.1:
|
||||
version "1.6.1"
|
||||
|
@ -17683,11 +17680,6 @@ utils-merge@1.0.1:
|
|||
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
||||
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
||||
|
||||
uuid@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a"
|
||||
integrity sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=
|
||||
|
||||
uuid@^3.0.1, uuid@^3.3.2, uuid@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
||||
|
|
Loading…
Reference in New Issue