Skip to content

Commit 33a6587

Browse files
[MOO-2017] removing react-native-schedule-exact-alarm-permission and update react-native-permissions (#297)
2 parents 39e9d73 + 436af01 commit 33a6587

File tree

7 files changed

+63
-54
lines changed

7 files changed

+63
-54
lines changed

configs/e2e/native_dependencies.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"react-native-file-viewer-turbo": "0.6.0",
1717
"react-native-localize": "3.2.1",
1818
"react-native-image-picker": "7.2.3",
19-
"react-native-permissions": "4.1.5",
19+
"react-native-permissions": "5.4.2",
2020
"react-native-webview": "13.13.2"
2121
}

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

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import fg from "fast-glob";
44
import fsExtra from "fs-extra";
5-
import { existsSync, readFileSync, writeFileSync } from "fs";
5+
import { existsSync, readFileSync, writeFileSync, cpSync, lstatSync, realpathSync } from "fs";
66
import { dirname, join, parse } from "path";
7-
import copy from "recursive-copy";
87
import { promisify } from "util";
98
import resolve from "resolve";
109
import _ from "lodash";
@@ -172,15 +171,36 @@ export async function copyJsModule(moduleSourcePath, to) {
172171
if (existsSync(to)) {
173172
return;
174173
}
175-
return promisify(copy)(moduleSourcePath, to, {
176-
filter: [
177-
"**/*.*",
178-
LICENSE_GLOB,
179-
"!**/{android,ios,windows,mac,jest,github,gradle,__*__,docs,jest,example*}/**/*",
180-
"!**/*.{config,setup}.*",
181-
"!**/*.{podspec,flow}"
182-
],
183-
overwrite: true
174+
175+
// Check if the source is a symlink and resolve it to the actual path
176+
let actualSourcePath = moduleSourcePath;
177+
if (lstatSync(moduleSourcePath).isSymbolicLink()) {
178+
actualSourcePath = realpathSync(moduleSourcePath);
179+
}
180+
181+
cpSync(actualSourcePath, to, {
182+
recursive: true,
183+
dereference: true, // Follow symlinks and copy the actual files
184+
filter: (src, dest) => {
185+
const relativePath = src.replace(actualSourcePath, "").replace(/^[\\/]/, "");
186+
187+
// Skip certain directories
188+
if (relativePath.match(/[\\/](android|ios|windows|mac|jest|github|gradle|__.*__|docs|example.*)[\\/]/)) {
189+
return false;
190+
}
191+
192+
// Skip certain file types
193+
if (relativePath.match(/\.(config|setup)\.|\.podspec$|\.flow$/)) {
194+
return false;
195+
}
196+
197+
// Include LICENSE files
198+
if (relativePath.match(/license/i)) {
199+
return true;
200+
}
201+
202+
return true;
203+
}
184204
});
185205
}
186206

configs/jsactions/rollup.config.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ export default async args => {
9393
}
9494
);
9595

96-
// We dynamically import react-native-schedule-exact-alarm-permission as it works only on Android
97-
// so we need to copy it here as collectDependencies won't detect it.
98-
await copyJsModule(
99-
// require returns a path to commonjs index.js file
100-
join(
101-
dirname(require.resolve("react-native-schedule-exact-alarm-permission")),
102-
"../",
103-
"../"
104-
),
105-
join(outDir, "node_modules", "react-native-schedule-exact-alarm-permission")
106-
);
10796
} else if (args.configProject === "nanoflowcommons") {
10897
// `invariant` is being used silently by @react-native-community/geolocation; it is not listed as a dependency nor peerDependency.
10998
// 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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
10+
- We updated react-native-permissions to 5.4.2.
11+
12+
- We removed react-native-schedule-exact-alarm-permission since it's no longer required.
13+
914
- Updated react-native from version 0.75.4 to 0.77.3.
1015
- We migrated from react-native-file-viewer to react-native-file-viewer-turbo for new architecture compatibility
1116
- File viewer now uses modal to display content
1217

18+
1319
## [10.0.0] Native Mobile Resources - 2025-3-31
1420

1521
- We migrated from react-native-inappbrowser-reborn to @swan-io/react-native-browser to prevent issues for next rn upgrade.

packages/jsActions/mobile-resources-native/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
"react-native-file-viewer-turbo": "0.6.0",
3939
"react-native-image-picker": "7.2.3",
4040
"react-native-localize": "3.2.1",
41-
"react-native-permissions": "4.1.5",
42-
"react-native-schedule-exact-alarm-permission": "^0.1.3",
41+
"react-native-permissions": "5.4.2",
4342
"react-native-sound": "0.11.0",
4443
"url-parse": "^1.4.7"
4544
},

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
RESULTS,
1313
openSettings,
1414
Permission,
15-
PERMISSIONS as RNPermissions
15+
PERMISSIONS as RNPermissions,
16+
canScheduleExactAlarms
1617
} from "react-native-permissions";
1718
import { ANDROIDPermissionName, IOSPermissionName } from "../../typings/RequestGenericPermission";
1819

@@ -30,18 +31,26 @@ function handleBlockedPermission(permission: string): void {
3031
const permissionName = permission.replace(/_IOS|_ANDROID/, "");
3132

3233
if (permissionName === "SCHEDULE_EXACT_ALARM") {
33-
const RNExactAlarmPermission = require("react-native-schedule-exact-alarm-permission");
34-
35-
Alert.alert("", "Please allow setting alarms and reminders", [
36-
{ text: "Go to alarm settings", onPress: () => RNExactAlarmPermission.getPermission(), isPreferred: true },
37-
{ text: "Cancel", style: "cancel" }
38-
]);
39-
} else {
40-
Alert.alert("", `Please allow ${permissionName} access`, [
41-
{ text: "Go to settings", onPress: () => openSettings(), isPreferred: true },
34+
return Alert.alert("", "Please allow setting alarms and reminders", [
35+
{
36+
text: "Go to alarm settings",
37+
onPress: async () => {
38+
const canSchedule = await canScheduleExactAlarms();
39+
if (!canSchedule) {
40+
// Check if permission is already granted
41+
return openSettings("alarms");
42+
}
43+
return openSettings();
44+
},
45+
isPreferred: true
46+
},
4247
{ text: "Cancel", style: "cancel" }
4348
]);
4449
}
50+
return Alert.alert("", `Please allow ${permissionName} access`, [
51+
{ text: "Go to settings", onPress: () => openSettings(), isPreferred: true },
52+
{ text: "Cancel", style: "cancel" }
53+
]);
4554
}
4655

4756
function mapPermissionName(permissionName: string): Permission | "android.permission.SCHEDULE_EXACT_ALARM" | undefined {

pnpm-lock.yaml

Lines changed: 5 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)