Skip to content

Commit d63c590

Browse files
[MOO-1492] Conditionally import RN schedule exact alarm permission (#143)
2 parents 5914337 + d3205b4 commit d63c590

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

configs/jsactions/rollup-plugin-collect-dependencies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async function getTransitiveDependencies(packagePath, isExternal) {
166166
return Array.from(result);
167167
}
168168

169-
async function copyJsModule(moduleSourcePath, to) {
169+
export async function copyJsModule(moduleSourcePath, to) {
170170
if (existsSync(to)) {
171171
return;
172172
}

configs/jsactions/rollup.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import command from "rollup-plugin-command";
1010
import { promisify } from "util";
1111
import { nodeResolve } from "@rollup/plugin-node-resolve";
1212
import typescript from "@rollup/plugin-typescript";
13-
import { collectDependencies } from "./rollup-plugin-collect-dependencies";
13+
import { collectDependencies, copyJsModule } from "./rollup-plugin-collect-dependencies";
1414
import { licenseCustomTemplate, copyLicenseFile } from "./rollup-helper";
1515
import { bigJsImportReplacer } from "./rollup-plugin-bigjs-import-replacer";
1616

@@ -90,6 +90,18 @@ export default async args => {
9090
overwrite: true
9191
}
9292
);
93+
94+
// We dynamically import react-native-schedule-exact-alarm-permission as it works only on Android
95+
// so we need to copy it here as collectDependencies won't detect it.
96+
await copyJsModule(
97+
// require returns a path to commonjs index.js file
98+
join(
99+
dirname(require.resolve("react-native-schedule-exact-alarm-permission")),
100+
"../",
101+
"../"
102+
),
103+
join(outDir, "node_modules", "react-native-schedule-exact-alarm-permission")
104+
);
93105
} else if (args.configProject === "nanoflowcommons") {
94106
// `invariant` is being used silently by @react-native-community/geolocation; it is not listed as a dependency nor peerDependency.
95107
// https://github.dev/react-native-geolocation/react-native-geolocation/blob/1786929f2be581da91082ff857c2393da5e597b3/js/implementation.native.js#L13

packages/jsActions/mobile-resources-native/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
- We have fixed an issue with checking blocked permissions on iOS
10+
911
## [6.1.0] Native Mobile Resources - 2024-05-28
1012

1113
### Changed

packages/jsActions/mobile-resources-native/src/permissions/RequestGenericPermission.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
Permission,
1515
PERMISSIONS as RNPermissions
1616
} from "react-native-permissions";
17-
import { getPermission } from "react-native-schedule-exact-alarm-permission";
1817
import { ANDROIDPermissionName, IOSPermissionName } from "../../typings/RequestGenericPermission";
1918

2019
// BEGIN EXTRA CODE
@@ -31,8 +30,10 @@ function handleBlockedPermission(permission: string): void {
3130
const permissionName = permission.replace(/_IOS|_ANDROID/, "");
3231

3332
if (permissionName === "SCHEDULE_EXACT_ALARM") {
33+
const RNExactAlarmPermission = require("react-native-schedule-exact-alarm-permission");
34+
3435
Alert.alert("", "Please allow setting alarms and reminders", [
35-
{ text: "Go to alarm settings", onPress: () => getPermission(), isPreferred: true },
36+
{ text: "Go to alarm settings", onPress: () => RNExactAlarmPermission.getPermission(), isPreferred: true },
3637
{ text: "Cancel", style: "cancel" }
3738
]);
3839
} else {

packages/jsActions/nanoflow-actions-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
"eslint": "^7.20.0",
3737
"rollup": "^2.68.0"
3838
}
39-
}
39+
}

0 commit comments

Comments
 (0)