Skip to content

Commit

Permalink
fix: conditionally import RN schedule exact alarm
Browse files Browse the repository at this point in the history
  • Loading branch information
vadymv-mendix committed Jun 24, 2024
1 parent 2aa15fc commit e1723e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
Permission,
PERMISSIONS as RNPermissions
} from "react-native-permissions";
import { getPermission } from "react-native-schedule-exact-alarm-permission";
import { ANDROIDPermissionName, IOSPermissionName } from "../../typings/RequestGenericPermission";

// BEGIN EXTRA CODE
Expand All @@ -27,12 +26,14 @@ const PERMISSIONS = {
IOS: RNPermissions.IOS
};

function handleBlockedPermission(permission: string): void {
async function handleBlockedPermission(permission: string): Promise<void> {
const permissionName = permission.replace(/_IOS|_ANDROID/, "");

if (permissionName === "SCHEDULE_EXACT_ALARM") {
const RNExactAlarmPermission = await import("react-native-schedule-exact-alarm-permission");

Alert.alert("", "Please allow setting alarms and reminders", [
{ text: "Go to alarm settings", onPress: () => getPermission(), isPreferred: true },
{ text: "Go to alarm settings", onPress: () => RNExactAlarmPermission.getPermission(), isPreferred: true },
{ text: "Cancel", style: "cancel" }
]);
} else {
Expand Down Expand Up @@ -106,7 +107,7 @@ export async function RequestGenericPermission(
case RESULTS.LIMITED:
return permissionStatus;
case RESULTS.BLOCKED:
handleBlockedPermission(permission);
await handleBlockedPermission(permission);
return RESULTS.BLOCKED;
case RESULTS.DENIED:
return request(mappedPermissionName as Permission);
Expand Down
2 changes: 1 addition & 1 deletion packages/jsActions/nanoflow-actions-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"eslint": "^7.20.0",
"rollup": "^2.68.0"
}
}
}

0 comments on commit e1723e7

Please sign in to comment.