fix: patch setCategories to add support for multiple categories (#5490)
* fix: patch setCategories to accept more than one category * chore: set category to make easier to test * ci cache * update fastlane * update patch * wip * update patch * remove @ts-ignore
This commit is contained in:
parent
9c8aaa2c0c
commit
ec3cb3ac53
|
@ -35,15 +35,13 @@ export const pushNotificationConfigure = (onNotification: (notification: INotifi
|
||||||
buttonTitle: I18n.t('Reply'),
|
buttonTitle: I18n.t('Reply'),
|
||||||
placeholder: I18n.t('Type_message')
|
placeholder: I18n.t('Type_message')
|
||||||
});
|
});
|
||||||
const notificationCategory = new NotificationCategory('MESSAGE', [notificationAction]);
|
|
||||||
|
|
||||||
Notifications.setCategories([notificationCategory]);
|
|
||||||
|
|
||||||
const acceptAction = new NotificationAction('ACCEPT_ACTION', 'foreground', I18n.t('accept'), true);
|
const acceptAction = new NotificationAction('ACCEPT_ACTION', 'foreground', I18n.t('accept'), true);
|
||||||
const rejectAction = new NotificationAction('DECLINE_ACTION', 'foreground', I18n.t('decline'), true);
|
const rejectAction = new NotificationAction('DECLINE_ACTION', 'foreground', I18n.t('decline'), true);
|
||||||
|
|
||||||
|
const notificationCategory = new NotificationCategory('MESSAGE', [notificationAction]);
|
||||||
const videoConfCategory = new NotificationCategory('VIDEOCONF', [acceptAction, rejectAction]);
|
const videoConfCategory = new NotificationCategory('VIDEOCONF', [acceptAction, rejectAction]);
|
||||||
|
|
||||||
Notifications.setCategories([videoConfCategory]);
|
Notifications.setCategories([videoConfCategory, notificationCategory]);
|
||||||
} else if (Platform.OS === 'android' && Platform.constants.Version >= 33) {
|
} else if (Platform.OS === 'android' && Platform.constants.Version >= 33) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
PermissionsAndroid.request('android.permission.POST_NOTIFICATIONS').then(permissionStatus => {
|
PermissionsAndroid.request('android.permission.POST_NOTIFICATIONS').then(permissionStatus => {
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
"js-base64": "3.6.1",
|
"js-base64": "3.6.1",
|
||||||
"js-sha256": "^0.9.0",
|
"js-sha256": "^0.9.0",
|
||||||
"jsrsasign": "^10.8.6",
|
"jsrsasign": "^10.8.6",
|
||||||
"lint-staged": "^11.1.0",
|
"lint-staged": "11.1.0",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"moment": "2.29.4",
|
"moment": "2.29.4",
|
||||||
"pretty-bytes": "5.6.0",
|
"pretty-bytes": "5.6.0",
|
||||||
|
|
|
@ -116,6 +116,19 @@ index f9c858b..94ea188 100644
|
||||||
|
|
||||||
public abstract class NotificationManagerCompatFacade {
|
public abstract class NotificationManagerCompatFacade {
|
||||||
public static NotificationManagerCompat from(@NonNull Context context) {
|
public static NotificationManagerCompat from(@NonNull Context context) {
|
||||||
|
diff --git a/node_modules/react-native-notifications/lib/dist/Notifications.d.ts b/node_modules/react-native-notifications/lib/dist/Notifications.d.ts
|
||||||
|
index 6e49fd4..5fe9515 100644
|
||||||
|
--- a/node_modules/react-native-notifications/lib/dist/Notifications.d.ts
|
||||||
|
+++ b/node_modules/react-native-notifications/lib/dist/Notifications.d.ts
|
||||||
|
@@ -32,7 +32,7 @@ export declare class NotificationsRoot {
|
||||||
|
/**
|
||||||
|
* setCategories
|
||||||
|
*/
|
||||||
|
- setCategories(categories: [NotificationCategory?]): void;
|
||||||
|
+ setCategories(categories: NotificationCategory[]): void;
|
||||||
|
/**
|
||||||
|
* cancelLocalNotification
|
||||||
|
*/
|
||||||
diff --git a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h
|
diff --git a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h
|
||||||
index 8b2c269..8667351 100644
|
index 8b2c269..8667351 100644
|
||||||
--- a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h
|
--- a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h
|
||||||
|
@ -140,6 +153,31 @@ index 4bc5292..71df0bc 100644
|
||||||
|
|
||||||
@interface RNNotificationCenter : NSObject
|
@interface RNNotificationCenter : NSObject
|
||||||
|
|
||||||
|
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
|
||||||
|
index afd5c73..ec4dd85 100644
|
||||||
|
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
|
||||||
|
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
|
||||||
|
@@ -48,14 +48,15 @@ - (void)requestPermissions:(NSDictionary *)options {
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setCategories:(NSArray *)json {
|
||||||
|
- NSMutableSet<UNNotificationCategory *>* categories = nil;
|
||||||
|
+ NSMutableSet<UNNotificationCategory *>* categories = [NSMutableSet new];
|
||||||
|
|
||||||
|
- if ([json count] > 0) {
|
||||||
|
- categories = [NSMutableSet new];
|
||||||
|
- for (NSDictionary* categoryJson in json) {
|
||||||
|
- [categories addObject:[RCTConvert UNMutableUserNotificationCategory:categoryJson]];
|
||||||
|
+ for (NSDictionary* categoryJson in json) {
|
||||||
|
+ UNNotificationCategory *category = [RCTConvert UNMutableUserNotificationCategory:categoryJson];
|
||||||
|
+ if (category) {
|
||||||
|
+ [categories addObject:category];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories];
|
||||||
|
}
|
||||||
|
|
||||||
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationCenterListener.h b/node_modules/react-native-notifications/lib/ios/RNNotificationCenterListener.h
|
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationCenterListener.h b/node_modules/react-native-notifications/lib/ios/RNNotificationCenterListener.h
|
||||||
index 77a67dd..eaf0043 100644
|
index 77a67dd..eaf0043 100644
|
||||||
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationCenterListener.h
|
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationCenterListener.h
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
"alert": {
|
"alert": {
|
||||||
"title": "Hey!",
|
"title": "Hey!",
|
||||||
"body": "You have a new push"
|
"body": "You have a new push"
|
||||||
}
|
},
|
||||||
|
"category": "MESSAGE"
|
||||||
},
|
},
|
||||||
"ejson": "{ \"host\": \"https://open.rocket.chat/\", \"rid\": \"GENERAL\", \"type\": \"c\", \"name\": \"general\" }"
|
"ejson": "{ \"host\": \"https://open.rocket.chat/\", \"rid\": \"GENERAL\", \"type\": \"c\", \"name\": \"general\" }"
|
||||||
}
|
}
|
10
yarn.lock
10
yarn.lock
|
@ -8648,7 +8648,7 @@ bunyan@^1.8.12:
|
||||||
bytebuffer@^5.0.1:
|
bytebuffer@^5.0.1:
|
||||||
version "5.0.1"
|
version "5.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/bytebuffer/-/bytebuffer-5.0.1.tgz#582eea4b1a873b6d020a48d58df85f0bba6cfddd"
|
resolved "https://registry.yarnpkg.com/bytebuffer/-/bytebuffer-5.0.1.tgz#582eea4b1a873b6d020a48d58df85f0bba6cfddd"
|
||||||
integrity sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0=
|
integrity sha512-IuzSdmADppkZ6DlpycMkm8l9zeEq16fWtLvunEwFiYciR/BHo4E8/xs5piFquG+Za8OWmMqHF8zuRviz2LHvRQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
long "~3"
|
long "~3"
|
||||||
|
|
||||||
|
@ -14551,9 +14551,9 @@ jsonify@^0.0.1:
|
||||||
integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==
|
integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==
|
||||||
|
|
||||||
jsrsasign@^10.8.6:
|
jsrsasign@^10.8.6:
|
||||||
version "10.8.6"
|
version "10.9.0"
|
||||||
resolved "https://registry.yarnpkg.com/jsrsasign/-/jsrsasign-10.8.6.tgz#ebf7f3c812c6517af84f0d8a10115e0dbfabe145"
|
resolved "https://registry.yarnpkg.com/jsrsasign/-/jsrsasign-10.9.0.tgz#cc3f316e7e4c112a976193f9d2c93deb5a0745ee"
|
||||||
integrity sha512-bQmbVtsfbgaKBTWCKiDCPlUPbdlRIK/FzSwT3BzIgZl/cU6TqXu6pZJsCI/dJVrZ9Gir5GC4woqw9shH/v7MBw==
|
integrity sha512-QWLUikj1SBJGuyGK8tjKSx3K7Y69KYJnrs/pQ1KZ6wvZIkHkWjZ1PJDpuvc1/28c1uP0KW9qn1eI1LzHQqDOwQ==
|
||||||
|
|
||||||
"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.2.1:
|
"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.2.1:
|
||||||
version "3.3.0"
|
version "3.3.0"
|
||||||
|
@ -14657,7 +14657,7 @@ lines-and-columns@^1.1.6:
|
||||||
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
|
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
|
||||||
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
|
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
|
||||||
|
|
||||||
lint-staged@^11.1.0:
|
lint-staged@11.1.0:
|
||||||
version "11.1.0"
|
version "11.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.1.0.tgz#a21d67ffe4516e907635adeaf6d6450d8cffb4e4"
|
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.1.0.tgz#a21d67ffe4516e907635adeaf6d6450d8cffb4e4"
|
||||||
integrity sha512-pzwEf+NKbTauAlk7gPPwTfulRXESEPZCSFXYfg20F220UOObebxu5uL5mkr9csQLNOM2Ydfrt3DJXakzAL7aaQ==
|
integrity sha512-pzwEf+NKbTauAlk7gPPwTfulRXESEPZCSFXYfg20F220UOObebxu5uL5mkr9csQLNOM2Ydfrt3DJXakzAL7aaQ==
|
||||||
|
|
Loading…
Reference in New Issue