feat: gate download behind development certificate on iOS

This commit is contained in:
Adrian Castro
2024-04-01 23:44:49 +02:00
parent 683cab9796
commit 7b1dd8170d
11 changed files with 181 additions and 4 deletions

View File

@@ -1,18 +1,25 @@
import type { Asset } from "expo-media-library";
import React from "react";
import { Alert, Platform } from "react-native";
import { ScrollView } from "react-native-gesture-handler";
import { useRouter } from "expo-router";
import { useFocusEffect, useRouter } from "expo-router";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { isDevelopmentProvisioningProfile } from "modules/check-ios-certificate";
import { useTheme, YStack } from "tamagui";
import type { ScrapeMedia } from "@movie-web/provider-utils";
import { DownloadItem } from "~/components/DownloadItem";
import ScreenLayout from "~/components/layout/ScreenLayout";
import { MWButton } from "~/components/ui/Button";
import { useDownloadManager } from "~/hooks/DownloadManagerContext";
import { usePlayerStore } from "~/stores/player/store";
const DownloadsScreen: React.FC = () => {
const { startDownload, downloads } = useDownloadManager();
const resetVideo = usePlayerStore((state) => state.resetVideo);
@@ -20,6 +27,23 @@ const DownloadsScreen: React.FC = () => {
const router = useRouter();
const theme = useTheme();
useFocusEffect(
React.useCallback(() => {
if (Platform.OS === "ios" && !isDevelopmentProvisioningProfile()) {
Alert.alert(
"Production Certificate",
"Download functionality is not available when the application is signed with a distribution certificate.",
[
{
text: "OK",
onPress: () => router.back(),
},
],
);
}
}, [router]),
);
const handlePress = (asset?: Asset) => {
if (!asset) return;
resetVideo();
@@ -44,6 +68,9 @@ const DownloadsScreen: React.FC = () => {
tmdbId: "98765",
},
};
console.log(isDevelopmentProvisioningProfile());
return (
<ScreenLayout>
<YStack gap={2} style={{ padding: 10 }}>
@@ -101,4 +128,4 @@ const DownloadsScreen: React.FC = () => {
);
};
export default DownloadsScreen;
export default DownloadsScreen;