diff --git a/configs/jsactions/rollup-plugin-collect-dependencies.js b/configs/jsactions/rollup-plugin-collect-dependencies.js index e3ac7232c..0e1fef384 100644 --- a/configs/jsactions/rollup-plugin-collect-dependencies.js +++ b/configs/jsactions/rollup-plugin-collect-dependencies.js @@ -166,7 +166,7 @@ async function getTransitiveDependencies(packagePath, isExternal) { return Array.from(result); } -async function copyJsModule(moduleSourcePath, to) { +export async function copyJsModule(moduleSourcePath, to) { if (existsSync(to)) { return; } diff --git a/configs/jsactions/rollup.config.js b/configs/jsactions/rollup.config.js index b60176311..9435b7d3d 100644 --- a/configs/jsactions/rollup.config.js +++ b/configs/jsactions/rollup.config.js @@ -10,7 +10,7 @@ import command from "rollup-plugin-command"; import { promisify } from "util"; import { nodeResolve } from "@rollup/plugin-node-resolve"; import typescript from "@rollup/plugin-typescript"; -import { collectDependencies } from "./rollup-plugin-collect-dependencies"; +import { collectDependencies, copyJsModule } from "./rollup-plugin-collect-dependencies"; import { licenseCustomTemplate, copyLicenseFile } from "./rollup-helper"; import { bigJsImportReplacer } from "./rollup-plugin-bigjs-import-replacer"; @@ -90,6 +90,18 @@ export default async args => { overwrite: true } ); + + // We dynamically import react-native-schedule-exact-alarm-permission as it works only on Android + // so we need to copy it here as collectDependencies won't detect it. + await copyJsModule( + // require returns a path to commonjs index.js file + join( + dirname(require.resolve("react-native-schedule-exact-alarm-permission")), + "../", + "../" + ), + join(outDir, "node_modules", "react-native-schedule-exact-alarm-permission") + ); } else if (args.configProject === "nanoflowcommons") { // `invariant` is being used silently by @react-native-community/geolocation; it is not listed as a dependency nor peerDependency. // https://github.dev/react-native-geolocation/react-native-geolocation/blob/1786929f2be581da91082ff857c2393da5e597b3/js/implementation.native.js#L13 diff --git a/packages/jsActions/mobile-resources-native/CHANGELOG.md b/packages/jsActions/mobile-resources-native/CHANGELOG.md index 3d6809a15..798659b7e 100644 --- a/packages/jsActions/mobile-resources-native/CHANGELOG.md +++ b/packages/jsActions/mobile-resources-native/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +- We have fixed an issue with checking blocked permissions on iOS + ## [6.1.0] Native Mobile Resources - 2024-05-28 ### Changed diff --git a/packages/jsActions/mobile-resources-native/src/permissions/RequestGenericPermission.ts b/packages/jsActions/mobile-resources-native/src/permissions/RequestGenericPermission.ts index 83b2513a2..dc44d1ccb 100644 --- a/packages/jsActions/mobile-resources-native/src/permissions/RequestGenericPermission.ts +++ b/packages/jsActions/mobile-resources-native/src/permissions/RequestGenericPermission.ts @@ -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 @@ -31,8 +30,10 @@ function handleBlockedPermission(permission: string): void { const permissionName = permission.replace(/_IOS|_ANDROID/, ""); if (permissionName === "SCHEDULE_EXACT_ALARM") { + const RNExactAlarmPermission = require("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 { diff --git a/packages/jsActions/nanoflow-actions-native/package.json b/packages/jsActions/nanoflow-actions-native/package.json index ec8f6d4d0..9bfda663f 100644 --- a/packages/jsActions/nanoflow-actions-native/package.json +++ b/packages/jsActions/nanoflow-actions-native/package.json @@ -36,4 +36,4 @@ "eslint": "^7.20.0", "rollup": "^2.68.0" } -} \ No newline at end of file +}