From 48a95d5141fbfc56020e70385d1fc1c3aa2058e8 Mon Sep 17 00:00:00 2001 From: DanielEliraz Date: Tue, 29 Jun 2021 17:41:13 +0300 Subject: [PATCH] Add ability to request/check more iOS permissions (#752) Co-authored-by: Vincent Pizzo --- example/index.js | 17 ++++-- lib/ios/RNBridgeModule.m | 2 +- lib/ios/RNCommandsHandler.h | 2 +- lib/ios/RNCommandsHandler.m | 2 +- lib/ios/RNNotificationCenter.h | 2 +- lib/ios/RNNotificationCenter.m | 56 +++++++++++++------ .../RNCommandsHandlerIntegrationTest.m | 33 ++++++----- lib/src/Notifications.ts | 5 +- lib/src/NotificationsIOS.ts | 5 +- lib/src/adapters/NativeCommandsSender.ts | 11 ++-- lib/src/commands/Commands.test.ts | 22 +++++++- lib/src/commands/Commands.ts | 5 +- lib/src/interfaces/NotificationPermissions.ts | 9 ++- website/docs/api/general-api.md | 4 +- website/docs/api/ios-api.md | 21 ++++--- website/docs/docs/subscription.md | 4 ++ 16 files changed, 130 insertions(+), 70 deletions(-) diff --git a/example/index.js b/example/index.js index 7fe95a72d..3d097fbbf 100644 --- a/example/index.js +++ b/example/index.js @@ -54,7 +54,9 @@ class NotificationsExampleApp extends Component { } requestPermissionsIos(options) { - Notifications.ios.registerRemoteNotifications(options); + Notifications.ios.registerRemoteNotifications( + Object.fromEntries(options.map(opt => [opt, true])) + ); } requestPermissions() { @@ -146,6 +148,12 @@ class NotificationsExampleApp extends Component { ); } + checkPermissions() { + Notifications.ios.checkPermissions().then((currentPermissions) => { + console.warn(currentPermissions); + }); + } + render() { const notifications = this.state.notifications.map((notification, idx) => ( @@ -163,9 +171,10 @@ class NotificationsExampleApp extends Component {