Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOO-1492] Conditionally import RN schedule exact alarm permission #143

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/jsactions/rollup-plugin-collect-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 13 additions & 1 deletion configs/jsactions/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/jsActions/mobile-resources-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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 @@ -31,8 +30,10 @@
const permissionName = permission.replace(/_IOS|_ANDROID/, "");

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

Check warning on line 33 in packages/jsActions/mobile-resources-native/src/permissions/RequestGenericPermission.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Require statement not part of import statement

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
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"
}
}
}
Loading