Skip to content

Moo 1800/update dependencies #262

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions configs/e2e/native_dependencies.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"react-native-maps": "1.14.0",
"react-native-geocoder": "0.5.0",
"react-native-device-info": "13.0.0",
"react-native-device-info": "14.0.4",
"react-native-action-button": "2.8.5",
"react-native-material-menu": "1.2.0",
"react-native-linear-gradient": "2.5.6",
"react-native-linear-gradient": "2.8.3",
"@react-native-community/netinfo": "11.4.1",
"react-native-svg": "15.7.1",
"react-native-system-navigation-bar": "2.6.3",
Expand Down
14 changes: 6 additions & 8 deletions packages/jsActions/mobile-resources-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,30 @@
"release:marketplace": "node ../../../scripts/release/marketplaceRelease.js"
},
"dependencies": {
"@notifee/react-native": "9.1.8",
"@react-native-camera-roll/camera-roll": "7.4.0",
"@react-native-community/push-notification-ios": "1.10.1",
"@react-native-firebase/messaging": "17.3.0",
"@swan-io/react-native-browser": "^0.4.1",
"@swan-io/react-native-browser": "0.4.1",
"fbjs": "3.0.4",
"mime": "3.0.0",
"react-native-biometrics": "3.0.1",
"react-native-blob-util": "0.21.2",
"react-native-device-info": "13.0.0",
"react-native-device-info": "14.0.4",
"react-native-file-viewer": "2.1.5",
"react-native-image-picker": "7.2.3",
"react-native-localize": "3.2.1",
"react-native-permissions": "4.1.5",
"react-native-push-notification": "8.1.1",
"react-native-schedule-exact-alarm-permission": "^0.1.3",
"react-native-sound": "0.11.0",
"react-native-touch-id": "4.4.1",
"react-native-track-player": "^4.1.1",
"url-parse": "^1.4.7"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "^10.0.1",
"@types/querystringify": "^2.0.0",
"@types/react-native-push-notification": "8.1.1",
"@types/url-parse": "^1.4.3",
"eslint": "^7.32.0",
"mendix": "~10.0.9976",
"rimraf": "^4.4.1",
"rollup": "^2.79.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import TouchID from "react-native-touch-id";
import ReactNativeBiometrics from "react-native-biometrics";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -16,9 +16,12 @@ import TouchID from "react-native-touch-id";
*/
export async function BiometricAuthentication(reason?: string): Promise<boolean> {
// BEGIN USER CODE
// Documentation https://github.com/naoufal/react-native-touch-id
// Documentation https://github.com/smallcase/react-native-simple-biometrics

return TouchID.authenticate(reason)
const rnBiometrics = new ReactNativeBiometrics();

return rnBiometrics
.simplePrompt({ promptMessage: reason ?? "" })
.then(() => true)
.catch(() => false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import TouchID from "react-native-touch-id";
import ReactNativeBiometrics from "react-native-biometrics";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -15,10 +15,13 @@ import TouchID from "react-native-touch-id";
*/
export async function IsBiometricAuthenticationSupported(): Promise<boolean> {
// BEGIN USER CODE
// Documentation https://github.com/naoufal/react-native-touch-id
// Documentation https://github.com/smallcase/react-native-simple-biometrics

return TouchID.isSupported()
.then(() => true)
const rnBiometrics = new ReactNativeBiometrics();

return rnBiometrics
.isSensorAvailable()
.then(result => result.available)
.catch(() => false);

// END USER CODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { NativeModules, Platform } from "react-native";
import PushNotification from "react-native-push-notification";
import { NativeModules } from "react-native";
import notifee from "@notifee/react-native";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -17,13 +17,12 @@ import PushNotification from "react-native-push-notification";
*/
export async function CancelAllScheduledNotifications(): Promise<void> {
// BEGIN USER CODE
// Documentation https://github.com/zo0r/react-native-push-notification
const isIOS = Platform.OS === "ios";
if (NativeModules && isIOS && !NativeModules.RNCPushNotificationIOS) {
return Promise.reject(new Error("Notifications module is not available in your app"));
// Documentation https://github.com/invertase/notifee
if (NativeModules && !NativeModules.NotifeeApiModule) {
return Promise.reject(new Error("Notifee native module is not available in your app"));
}

PushNotification.cancelAllLocalNotifications();
notifee.cancelAllNotifications();
return Promise.resolve();

// END USER CODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { NativeModules, Platform } from "react-native";
import PushNotification from "react-native-push-notification";
import { NativeModules } from "react-native";
import notifee from "@notifee/react-native";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -17,17 +17,16 @@ import PushNotification from "react-native-push-notification";
*/
export async function CancelScheduledNotification(notificationId?: string): Promise<void> {
// BEGIN USER CODE
// Documentation https://github.com/zo0r/react-native-push-notification
const isIOS = Platform.OS === "ios";
if (NativeModules && isIOS && !NativeModules.RNCPushNotificationIOS) {
return Promise.reject(new Error("Notifications module is not available in your app"));
// Documentation Documentation https://github.com/invertase/notifee
if (NativeModules && !NativeModules.NotifeeApiModule) {
return Promise.reject(new Error("Notifee native module is not available in your app"));
}

if (!notificationId) {
return Promise.reject(new Error("Input parameter 'Notification id' is required"));
}

PushNotification.cancelLocalNotification(notificationId);
notifee.cancelNotification(notificationId);
return Promise.resolve();

// END USER CODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { NativeModules, Platform } from "react-native";
import PushNotification from "react-native-push-notification";
import { NativeModules } from "react-native";
import notifee from "@notifee/react-native";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -17,13 +17,12 @@ import PushNotification from "react-native-push-notification";
*/
export async function ClearAllDeliveredNotifications(): Promise<void> {
// BEGIN USER CODE
// Documentation https://github.com/zo0r/react-native-push-notification
const isIOS = Platform.OS === "ios";
if (NativeModules && isIOS && !NativeModules.RNCPushNotificationIOS) {
return Promise.reject(new Error("Notifications module is not available in your app"));
// Documentation Documentation https://github.com/invertase/notifee
if (NativeModules && !NativeModules.NotifeeApiModule) {
return Promise.reject(new Error("Notifee native module is not available in your app"));
}

PushNotification.removeAllDeliveredNotifications();
notifee.cancelAllNotifications();

return Promise.resolve();
// END USER CODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { NativeModules, Platform } from "react-native";
import PushNotification, { PushNotificationObject } from "react-native-push-notification";
import notifee, { AndroidChannel, AndroidImportance, Notification } from "@notifee/react-native";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -32,59 +32,60 @@ export async function DisplayNotification(
actionGuid?: string
): Promise<void> {
// BEGIN USER CODE
// Documentation https://github.com/zo0r/react-native-push-notification

const isIOS = Platform.OS === "ios";
if (NativeModules && isIOS && !NativeModules.RNCPushNotificationIOS) {
return Promise.reject(new Error("Notifications module is not available in your app"));
if (!body) {
throw new Error("Input parameter 'Body' is required");
}

if (!body) {
return Promise.reject(new Error("Input parameter 'Body' is required"));
// Documentation Documentation https://github.com/invertase/notifee
if (NativeModules && !NativeModules.NotifeeApiModule) {
return Promise.reject(new Error("Notifee native module is not available in your app"));
}

const notification = { message: body } as PushNotificationObject;
const channelId = "mendix-local-notifications";
await createNotificationChannelIfNeeded(channelId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the channel is Android specific I'd call this function only when we're running on Android.


if (!isIOS) {
const channelId = "mendix-local-notifications";
const channelExists = await new Promise(resolve =>
PushNotification.channelExists(channelId, (exists: boolean) => resolve(exists))
);
if (!channelExists) {
const channel = await new Promise(resolve =>
PushNotification.createChannel(
{
channelId,
channelName: "Local notifications"
},
created => resolve(created)
)
);
if (!channel) {
return Promise.reject(new Error("Could not create the local notifications channel"));
}
const notification: Notification = {
title: title || undefined,
body,
android: {
channelId
}
notification.channelId = channelId;
}
};

if (title) {
notification.title = title;
if (subtitle && Platform.OS === "ios") {
notification.subtitle = subtitle;
}

if (subtitle && !isIOS) {
notification.subText = subtitle;
if (actionName || actionGuid) {
notification.data = {
actionName: actionName ?? "",
guid: actionGuid ?? ""
};
}

notification.playSound = !!playSound;
await notifee.displayNotification(notification);

if (actionName || actionGuid) {
notification.userInfo = {
actionName,
guid: actionGuid
async function createNotificationChannelIfNeeded(channelId: string): Promise<void> {
if (Platform.OS === "ios") {
return;
}
const existingChannel = await notifee.getChannel(channelId);
const sound = playSound ? "default" : undefined;
const channel: AndroidChannel = {
id: channelId,
name: "Local Notifications",
importance: AndroidImportance.HIGH,
...(playSound ? { sound: "default" } : {})
};
if (existingChannel === null) {
await notifee.createChannel(channel);
}
if (existingChannel?.sound !== sound) {
await notifee.deleteChannel(channelId);
await notifee.createChannel(channel);
}
}

PushNotification.localNotification(notification);
return Promise.resolve();
// END USER CODE
}
Loading
Loading