Skip to content

Commit

Permalink
example app - add permission native button
Browse files Browse the repository at this point in the history
* Also fix syntax for requestPermission
  • Loading branch information
nan-li committed Oct 23, 2023
1 parent 6b9ac44 commit c281499
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/RNOneSignalTS/src/OSButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ class OSButtons extends React.Component<Props> {
},
);

const permissionNativeButton = renderButtonView(
'Permission Native',
async () => {
const granted = await OneSignal.Notifications.permissionNative();
loggingFunction(`Permission Native: ${granted}`);
},
);

const canRequestPermissionButton = renderButtonView(
'Can Request Permission',
async () => {
Expand All @@ -151,9 +159,8 @@ class OSButtons extends React.Component<Props> {
'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}`);
},
);

Expand All @@ -167,6 +174,7 @@ class OSButtons extends React.Component<Props> {

return [
hasPermissionButton,
permissionNativeButton,
canRequestPermissionButton,
requestPermissionButton,
clearOneSignalNotificationsButton,
Expand Down

0 comments on commit c281499

Please sign in to comment.