diff --git a/locales/en/index.yml b/locales/en/index.yml
index 4e1a03a7de4..8c2b33fac22 100644
--- a/locales/en/index.yml
+++ b/locales/en/index.yml
@@ -752,6 +752,7 @@ authentication:
title: We can't find the CieID app
description: To login, you must have the app installed on your device.
primary_action_label: Get the app
+ link_error: We could not direct you to the store. Open it manually and search for CieID
cie:
genericTitle: Login with CIE
cie: CIE
diff --git a/locales/it/index.yml b/locales/it/index.yml
index 32ec5c05be3..640a6ab0a72 100644
--- a/locales/it/index.yml
+++ b/locales/it/index.yml
@@ -752,6 +752,7 @@ authentication:
title: Non riusciamo a trovare l'app CieID
description: Per accedere, devi avere l'app installata sul tuo dispositivo.
primary_action_label: Scarica CieID
+ link_error: Non siamo riusciti a indirizzarti allo store. Aprilo manualmente e cerca CieID
cie:
genericTitle: Entra con CIE
cie: CIE
diff --git a/ts/features/cie/__tests__/CieIdNotInstalled.test.tsx b/ts/features/cie/__tests__/CieIdNotInstalled.test.tsx
index 1d5136c324d..23ac3e19dd3 100644
--- a/ts/features/cie/__tests__/CieIdNotInstalled.test.tsx
+++ b/ts/features/cie/__tests__/CieIdNotInstalled.test.tsx
@@ -1,4 +1,4 @@
-import { Linking, Platform } from "react-native";
+import { Platform } from "react-native";
import { fireEvent, render } from "@testing-library/react-native";
import React from "react";
import CieIdNotInstalled, {
@@ -6,10 +6,13 @@ import CieIdNotInstalled, {
CIE_ID_ANDROID_LINK,
CIE_ID_IOS_LINK
} from "../components/CieIdNotInstalled";
+import * as urlUtils from "../../../utils/url";
const UAT_ENV_ENABLE_STATES = [true, false];
const mockPopToTop = jest.fn();
+const mockOpenUrl = jest.spyOn(urlUtils, "openWebUrl");
+const anyFunction = expect.any(Function);
jest.mock("@react-navigation/native", () => ({
...jest.requireActual("@react-navigation/native"),
@@ -28,15 +31,13 @@ describe(CieIdNotInstalled, () => {
describe("Behavior on iOS", () => {
UAT_ENV_ENABLE_STATES.forEach(uatState => {
- it("Should open CIE_ID_IOS_LINK", () => {
+ it("Should open CIE_ID_IOS_LINK", async () => {
const { getByTestId } = render();
const openStore = getByTestId("cie-id-not-installed-open-store");
fireEvent.press(openStore);
- expect(jest.spyOn(Linking, "openURL")).toHaveBeenCalledWith(
- CIE_ID_IOS_LINK
- );
+ expect(mockOpenUrl).toHaveBeenCalledWith(CIE_ID_IOS_LINK, anyFunction);
expect(mockPopToTop).not.toHaveBeenCalled();
});
});
@@ -50,8 +51,9 @@ describe(CieIdNotInstalled, () => {
const openStore = getByTestId("cie-id-not-installed-open-store");
fireEvent.press(openStore);
- expect(jest.spyOn(Linking, "openURL")).toHaveBeenCalledWith(
- CIE_ID_ANDROID_LINK
+ expect(mockOpenUrl).toHaveBeenCalledWith(
+ CIE_ID_ANDROID_LINK,
+ anyFunction
);
expect(mockPopToTop).not.toHaveBeenCalled();
});
@@ -63,8 +65,9 @@ describe(CieIdNotInstalled, () => {
const openStore = getByTestId("cie-id-not-installed-open-store");
fireEvent.press(openStore);
- expect(jest.spyOn(Linking, "openURL")).toHaveBeenCalledWith(
- CIE_ID_ANDROID_COLL_LINK
+ expect(mockOpenUrl).toHaveBeenCalledWith(
+ CIE_ID_ANDROID_COLL_LINK,
+ anyFunction
);
expect(mockPopToTop).not.toHaveBeenCalled();
});
@@ -76,7 +79,7 @@ describe(CieIdNotInstalled, () => {
const popToTop = getByTestId("cie-id-not-installed-pop-to-top");
fireEvent.press(popToTop);
- expect(jest.spyOn(Linking, "openURL")).not.toHaveBeenCalled();
+ expect(mockOpenUrl).not.toHaveBeenCalled();
expect(mockPopToTop).toHaveBeenCalledTimes(1);
});
});
diff --git a/ts/features/cie/components/CieIdNotInstalled.tsx b/ts/features/cie/components/CieIdNotInstalled.tsx
index aec42c74e56..577f548fe9b 100644
--- a/ts/features/cie/components/CieIdNotInstalled.tsx
+++ b/ts/features/cie/components/CieIdNotInstalled.tsx
@@ -1,9 +1,11 @@
import React from "react";
-import { Linking, Platform } from "react-native";
+import { Platform } from "react-native";
+import { useIOToast } from "@pagopa/io-app-design-system";
import { OperationResultScreenContent } from "../../../components/screens/OperationResultScreenContent";
import { useIONavigation } from "../../../navigation/params/AppParamsList";
import I18n from "../../../i18n";
import { trackCieIdNotInstalledDownloadAction } from "../analytics";
+import { openWebUrl } from "../../../utils/url";
export const CIE_ID_IOS_LINK =
"https://apps.apple.com/it/app/cieid/id1504644677";
@@ -17,6 +19,7 @@ export type CieIdNotInstalledProps = {
const CieIdNotInstalled = ({ isUat }: CieIdNotInstalledProps) => {
const { popToTop } = useIONavigation();
+ const { error } = useIOToast();
return (
{
),
onPress: () => {
void trackCieIdNotInstalledDownloadAction();
- void Linking.openURL(
+ openWebUrl(
Platform.select({
ios: CIE_ID_IOS_LINK,
android: isUat ? CIE_ID_ANDROID_COLL_LINK : CIE_ID_ANDROID_LINK,
default: ""
- })
+ }),
+ () => {
+ error(
+ I18n.t("authentication.cie_id.cie_not_installed.link_error")
+ );
+ }
);
}
}}