From c281499b68a986abb05f304f3c02a8e72f17100f Mon Sep 17 00:00:00 2001 From: Nan Date: Mon, 23 Oct 2023 15:09:40 -0700 Subject: [PATCH] example app - add permission native button * Also fix syntax for requestPermission --- examples/RNOneSignalTS/src/OSButtons.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/RNOneSignalTS/src/OSButtons.tsx b/examples/RNOneSignalTS/src/OSButtons.tsx index 96c32ed5..20e73a65 100644 --- a/examples/RNOneSignalTS/src/OSButtons.tsx +++ b/examples/RNOneSignalTS/src/OSButtons.tsx @@ -139,6 +139,14 @@ class OSButtons extends React.Component { }, ); + const permissionNativeButton = renderButtonView( + 'Permission Native', + async () => { + const granted = await OneSignal.Notifications.permissionNative(); + loggingFunction(`Permission Native: ${granted}`); + }, + ); + const canRequestPermissionButton = renderButtonView( 'Can Request Permission', async () => { @@ -151,9 +159,8 @@ class OSButtons extends React.Component { 'Request Permission', async () => { loggingFunction('Requesting notification permission'); - OneSignal.Notifications.requestPermission(false, (granted) => { - loggingFunction(`Notification permission granted ${granted}`); - }); + const granted = await OneSignal.Notifications.requestPermission(false); + loggingFunction(`Notification permission granted ${granted}`); }, ); @@ -167,6 +174,7 @@ class OSButtons extends React.Component { return [ hasPermissionButton, + permissionNativeButton, canRequestPermissionButton, requestPermissionButton, clearOneSignalNotificationsButton,