Skip to content

Commit

Permalink
🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Nov 28, 2024
1 parent 401cfea commit 4112da7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "dotenv/config";
import type { IntercomPluginProps } from "@intercom/intercom-react-native/lib/typescript/expo-plugins/@types";
import type { withSentry } from "@sentry/react-native/expo";
import type { ExpoConfig } from "expo/config";
import type { AssetProps } from "expo-asset/plugin/build/withAssets";
import type { PluginConfigType as BuildPropertiesConfig } from "expo-build-properties/build/pluginConfig";
import type withCamera from "expo-camera/plugin/build/withCamera";
import type { FontProps } from "expo-font/plugin/build/withFonts";
Expand Down Expand Up @@ -103,6 +104,7 @@ export default {
],
} satisfies FontProps,
],
["expo-asset", { assets: ["src/assets/icon.png"] } satisfies AssetProps],
"expo-router",
[
"@intercom/intercom-react-native",
Expand Down
24 changes: 24 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/web-manifest.json",
"short_name": "Exa",
"name": "Exa",
"icons": [
{ "src": "favicon.ico", "type": "image/x-icon", "sizes": "48x48" },
{ "src": "assets/src/assets/icon.f9538ae2aa18c66272006c460191b34f.png", "type": "image/png", "sizes": "1024x1024" }
],
"id": "/",
"lang": "en",
"start_url": ".",
"display": "standalone",
"orientation": "portrait",
"theme_color": "#0BD8B6",
"background_color": "#171918",
"prefer_related_applications": true,
"related_applications": [
{
"platform": "play",
"id": "app.exactly",
"url": "https://play.google.com/store/apps/details?id=app.exactly"
}
]
}
1 change: 1 addition & 0 deletions src/app/+html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function HTML({ children }: { children: ReactNode }) {
name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover"
/>
<link rel="manifest" href="/manifest.json" />
<ScrollViewStyleReset />
</head>
<body>{children}</body>
Expand Down
4 changes: 4 additions & 0 deletions src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ToastProvider } from "@tamagui/toast";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
import { isRunningInExpoGo } from "expo";
import { useAssets } from "expo-asset";
import { type FontSource, useFonts } from "expo-font";
import { SplashScreen, Stack, useNavigationContainerRef } from "expo-router";
import React, { useEffect } from "react";
Expand All @@ -17,6 +18,7 @@ import BDOGroteskRegular from "../assets/fonts/BDOGrotesk-Regular.otf";
import IBMPlexMonoBold from "../assets/fonts/IBMPlexMono-Bold.otf";
import IBMPlexMonoRegular from "../assets/fonts/IBMPlexMono-Regular.otf";
import IBMPlexMonoSemiBold from "../assets/fonts/IBMPlexMono-SemiBold.otf";
import AppIcon from "../assets/icon.png";
import { OnboardingProvider } from "../components/context/OnboardingProvider";
import ThemeProvider from "../components/context/ThemeProvider";
import handleError from "../utils/handleError";
Expand All @@ -42,6 +44,7 @@ init({
spotlight: __DEV__,
});
const useServerFonts = typeof window === "undefined" ? useFonts : () => undefined;
const useServerAssets = typeof window === "undefined" ? useAssets : () => undefined;
const devtools = !!JSON.parse(process.env.EXPO_PUBLIC_DEVTOOLS ?? "false");

export default wrap(function RootLayout() {
Expand All @@ -54,6 +57,7 @@ export default wrap(function RootLayout() {
"IBMPlexMono-Regular": IBMPlexMonoRegular as FontSource,
"IBMPlexMono-SemiBold": IBMPlexMonoSemiBold as FontSource,
});
useServerAssets([AppIcon]);
useEffect(() => {
routingInstrumentation.registerNavigationContainer(navigationContainer);
}, [navigationContainer]);
Expand Down
3 changes: 3 additions & 0 deletions src/components/onboarding/Success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { StyleSheet } from "react-native";

import AccountCreatedBlob from "../../assets/images/account-created-blob.svg";
import AccountCreatedImage from "../../assets/images/account-created.svg";
import handleError from "../../utils/handleError";
import { requestPermission } from "../../utils/onesignal";
import ActionButton from "../shared/ActionButton";
import SafeView from "../shared/SafeView";
import Text from "../shared/Text";
Expand Down Expand Up @@ -35,6 +37,7 @@ export default function Success() {
marginTop="$s4"
marginBottom="$s5"
onPress={() => {
requestPermission().catch(handleError);
router.replace("/(app)");
}}
iconAfter={<ArrowRight color="$interactiveOnBaseBrandDefault" />}
Expand Down
12 changes: 9 additions & 3 deletions src/utils/onesignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ import handleError from "./handleError";

const appId = process.env.EXPO_PUBLIC_ONE_SIGNAL_APP_ID;

const { initialization, login, logout } = (
const { initialization, login, logout, requestPermission } = (
Platform.OS === "web" && typeof window !== "undefined"
? () => {
const { default: OneSignal } = require("react-onesignal") as typeof OneSignalWeb; // eslint-disable-line @typescript-eslint/no-require-imports, unicorn/prefer-module
return {
initialization: appId
? OneSignal.init({ appId, allowLocalhostAsSecureOrigin: __DEV__ }).catch(handleError)
? OneSignal.init({
appId,
allowLocalhostAsSecureOrigin: __DEV__,
notifyButton: { enabled: true, showCredit: false },
}).catch(handleError)
: Promise.resolve(),
login: (userId: string) => OneSignal.login(userId),
logout: () => OneSignal.logout(),
requestPermission: () => OneSignal.Notifications.requestPermission(),
};
}
: () => {
Expand All @@ -33,8 +38,9 @@ const { initialization, login, logout } = (
OneSignal.logout();
return Promise.resolve();
},
requestPermission: () => OneSignal.Notifications.requestPermission(true),
};
}
)();

export { initialization, login, logout };
export { initialization, login, logout, requestPermission };

0 comments on commit 4112da7

Please sign in to comment.