From 7415036a72b66a1b83cf4bec988d1e6f6705bae0 Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:59:07 -0800 Subject: [PATCH 1/2] add preview notify provider info to ci workflows --- .github/workflows/mobile-build.yml | 11 +++-- .github/workflows/mobile-update.yml | 12 ++++-- apps/tlon-mobile/README.md | 12 ++++++ .../android/app/google-services.json | 28 ++----------- apps/tlon-mobile/src/App.tsx | 17 ++++++++ .../src/components/SingletonWebview.tsx | 40 ------------------- apps/tlon-mobile/src/utils/notifications.ts | 27 +++++++++++++ 7 files changed, 75 insertions(+), 72 deletions(-) create mode 100644 apps/tlon-mobile/src/utils/notifications.ts diff --git a/.github/workflows/mobile-build.yml b/.github/workflows/mobile-build.yml index 026a436b79..8490333a7b 100644 --- a/.github/workflows/mobile-build.yml +++ b/.github/workflows/mobile-build.yml @@ -15,9 +15,6 @@ on: - all - android - ios -env: - NOTIFY_PROVIDER: rivfur-livmet - NOTIFY_SERVICE: groups-native jobs: deploy: runs-on: ubuntu-latest @@ -36,9 +33,15 @@ jobs: token: ${{ secrets.EXPO_TOKEN }} - name: Install dependencies run: npm ci + - name: Create build vars + id: vars + run: | + echo "profile=${{ inputs.profile || 'preview' }}" >> $GITHUB_OUTPUT - name: Build for selected platforms working-directory: ./apps/tlon-mobile - run: eas build --profile ${{ inputs.profile || 'preview' }} --platform ${{ inputs.platform || 'all' }} --non-interactive --auto-submit + run: eas build --profile ${{ steps.vars.outputs.profile }} --platform ${{ inputs.platform || 'all' }} --non-interactive --auto-submit env: EXPO_APPLE_ID: ${{ secrets.EXPO_APPLE_ID }} EXPO_APPLE_PASSWORD: ${{ secrets.EXPO_APPLE_PASSWORD }} + NOTIFY_PROVIDER: "${{ steps.vars.outputs.profile == 'preview' && 'binnec-dozzod-marnus' || 'rivfur-livmet' }}" + NOTIFY_SERVICE: "${{ steps.vars.outputs.profile == 'preview' && 'tlon-preview-release' || 'groups-native' }}" diff --git a/.github/workflows/mobile-update.yml b/.github/workflows/mobile-update.yml index 0087665408..f68441c4d9 100644 --- a/.github/workflows/mobile-update.yml +++ b/.github/workflows/mobile-update.yml @@ -15,9 +15,6 @@ on: - all - android - ios -env: - NOTIFY_PROVIDER: rivfur-livmet - NOTIFY_SERVICE: groups-native jobs: deploy: runs-on: ubuntu-latest @@ -36,6 +33,13 @@ jobs: token: ${{ secrets.EXPO_TOKEN }} - name: Install dependencies run: npm ci + - name: Create build vars + id: vars + run: | + echo "profile=${{ inputs.profile || 'preview' }}" >> $GITHUB_OUTPUT - name: Push update for selected platforms working-directory: ./apps/tlon-mobile - run: eas update --auto --profile ${{ inputs.profile || 'preview' }} --platform ${{ inputs.platform || 'all' }} --non-interactive + run: eas update --auto --profile ${{ steps.vars.outputs.profile }} --platform ${{ inputs.platform || 'all' }} --non-interactive + env: + NOTIFY_PROVIDER: "${{ steps.vars.outputs.profile == 'preview' && 'binnec-dozzod-marnus' || 'rivfur-livmet' }}" + NOTIFY_SERVICE: "${{ steps.vars.outputs.profile == 'preview' && 'tlon-preview-release' || 'groups-native' }}" diff --git a/apps/tlon-mobile/README.md b/apps/tlon-mobile/README.md index ca12dd70ba..677e954b2d 100644 --- a/apps/tlon-mobile/README.md +++ b/apps/tlon-mobile/README.md @@ -70,6 +70,18 @@ Plug in your iOS device or start the iPhone Simulator and run the application in npm run ios ``` +#### Run Preview Scheme + +Run the Preview version of the app by specifying `scheme` or `variant` in the run command: + +```sh +npm run ios -- --scheme=Landscape-preview +``` + +```sh +npm run android -- --variant=preview +``` + ## Deployment Deployment is handled by [Expo Application Services](https://expo.dev/eas). diff --git a/apps/tlon-mobile/android/app/google-services.json b/apps/tlon-mobile/android/app/google-services.json index 7f3b21a7f8..f99c9075f4 100644 --- a/apps/tlon-mobile/android/app/google-services.json +++ b/apps/tlon-mobile/android/app/google-services.json @@ -12,12 +12,7 @@ "package_name": "io.tlon.groups" } }, - "oauth_client": [ - { - "client_id": "543296749236-1l5r4ipguvjdh083t5j7h1eicqi21j0o.apps.googleusercontent.com", - "client_type": 3 - } - ], + "oauth_client": [], "api_key": [ { "current_key": "AIzaSyDm8-5daeW5B8j6i_RIoSvOgnx6Fo0gEOU" @@ -25,12 +20,7 @@ ], "services": { "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "543296749236-1l5r4ipguvjdh083t5j7h1eicqi21j0o.apps.googleusercontent.com", - "client_type": 3 - } - ] + "other_platform_oauth_client": [] } } }, @@ -41,12 +31,7 @@ "package_name": "io.tlon.groups.preview" } }, - "oauth_client": [ - { - "client_id": "543296749236-1l5r4ipguvjdh083t5j7h1eicqi21j0o.apps.googleusercontent.com", - "client_type": 3 - } - ], + "oauth_client": [], "api_key": [ { "current_key": "AIzaSyDm8-5daeW5B8j6i_RIoSvOgnx6Fo0gEOU" @@ -54,12 +39,7 @@ ], "services": { "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "543296749236-1l5r4ipguvjdh083t5j7h1eicqi21j0o.apps.googleusercontent.com", - "client_type": 3 - } - ] + "other_platform_oauth_client": [] } } } diff --git a/apps/tlon-mobile/src/App.tsx b/apps/tlon-mobile/src/App.tsx index 49507f8823..79627a3f6c 100644 --- a/apps/tlon-mobile/src/App.tsx +++ b/apps/tlon-mobile/src/App.tsx @@ -8,6 +8,8 @@ import { } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { TamaguiProvider } from '@tloncorp/ui'; +import type { Subscription } from 'expo-notifications'; +import { addNotificationResponseReceivedListener } from 'expo-notifications'; import { PostHogProvider } from 'posthog-react-native'; import { useEffect, useState } from 'react'; import { Alert, StatusBar, Text, View } from 'react-native'; @@ -23,6 +25,7 @@ import { useDeepLink } from './hooks/useDeepLink'; import { useIsDarkMode } from './hooks/useIsDarkMode'; import { useScreenOptions } from './hooks/useScreenOptions'; import { inviteShipWithLure } from './lib/hostingApi'; +import { connectNotifications } from './lib/notifications'; import { syncContacts } from './lib/sync'; import { useDevTools } from './lib/useDevTools'; import { TabStack } from './navigation/TabStack'; @@ -41,6 +44,7 @@ import { SignUpPasswordScreen } from './screens/SignUpPasswordScreen'; import { TlonLoginScreen } from './screens/TlonLoginScreen'; import { WelcomeScreen } from './screens/WelcomeScreen'; import type { OnboardingStackParamList } from './types'; +import { handleNotificationResponse } from './utils/notifications'; import { posthogAsync, trackError } from './utils/posthog'; import { getPathFromWer } from './utils/string'; @@ -62,9 +66,22 @@ const App = ({ wer: initialWer }: Props) => { const gotoPath = initialWer ? getPathFromWer(initialWer) : wer; useEffect(() => { + let notificationTapListener: Subscription | undefined; if (isAuthenticated) { + // Start notification tap listener + // This only seems to get triggered on iOS. Android handles the tap and other intents in native code. + notificationTapListener = addNotificationResponseReceivedListener( + handleNotificationResponse + ); + + connectNotifications(); syncContacts(); } + + return () => { + // Clean up listeners + notificationTapListener?.remove(); + }; }, [isAuthenticated]); useEffect(() => { diff --git a/apps/tlon-mobile/src/components/SingletonWebview.tsx b/apps/tlon-mobile/src/components/SingletonWebview.tsx index a4949ea038..05d33c7245 100644 --- a/apps/tlon-mobile/src/components/SingletonWebview.tsx +++ b/apps/tlon-mobile/src/components/SingletonWebview.tsx @@ -6,7 +6,6 @@ import { type WebAppAction, } from '@tloncorp/shared'; import * as Clipboard from 'expo-clipboard'; -import { addNotificationResponseReceivedListener } from 'expo-notifications'; import { useCallback, useEffect, useRef, useState } from 'react'; import { Alert, Linking, useColorScheme } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; @@ -19,9 +18,7 @@ import { useShip } from '../contexts/ship'; import { useWebViewContext } from '../contexts/webview/webview'; import { useWebView } from '../hooks/useWebView'; import WebAppHelpers from '../lib/WebAppHelpers'; -import { markChatRead } from '../lib/chatApi'; import { getHostingUser } from '../lib/hostingApi'; -// import { connectNotifications } from '../lib/notifications'; import { getHostingUserId, removeHostingToken, @@ -112,43 +109,6 @@ export const SingletonWebview = () => { } }; - useEffect(() => { - // Start notification tap listener - // This only seems to get triggered on iOS. Android handles the tap and other intents in native code. - const notificationTapListener = addNotificationResponseReceivedListener( - (response) => { - const { - actionIdentifier, - userText, - notification: { - request: { - content: { data }, - }, - }, - } = response; - if (actionIdentifier === 'markAsRead' && data.channelId) { - markChatRead(data.channelId); - } else if (actionIdentifier === 'reply' && userText) { - // Send reply - } else if (data.wer) { - // TODO: handle wer - // setUri((curr) => ({ - // ...curr, - // uri: createUri(shipUrl, data.wer), - // key: curr.key + 1, - // })); - } - } - ); - - // connectNotifications(); - - return () => { - // Clean up listeners - notificationTapListener.remove(); - }; - }, [shipUrl]); - // When this view regains focus from Manage Account, query for hosting user's details and bump back to login if an error occurs useFocusEffect( useCallback(() => { diff --git a/apps/tlon-mobile/src/utils/notifications.ts b/apps/tlon-mobile/src/utils/notifications.ts new file mode 100644 index 0000000000..d5aa3d9955 --- /dev/null +++ b/apps/tlon-mobile/src/utils/notifications.ts @@ -0,0 +1,27 @@ +import type { NotificationResponse } from 'expo-notifications'; + +import { markChatRead } from '../lib/chatApi'; + +export const handleNotificationResponse = (response: NotificationResponse) => { + const { + actionIdentifier, + userText, + notification: { + request: { + content: { data }, + }, + }, + } = response; + if (actionIdentifier === 'markAsRead' && data.channelId) { + markChatRead(data.channelId); + } else if (actionIdentifier === 'reply' && userText) { + // Send reply + } else if (data.wer) { + // TODO: handle wer + // setUri((curr) => ({ + // ...curr, + // uri: createUri(shipUrl, data.wer), + // key: curr.key + 1, + // })); + } +}; From d83e55db195318419d44ab2bf592149be33d6e09 Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:48:54 -0700 Subject: [PATCH 2/2] use changes from develop --- apps/tlon-mobile/src/App.tsx | 15 ------------ apps/tlon-mobile/src/utils/notifications.ts | 27 --------------------- 2 files changed, 42 deletions(-) delete mode 100644 apps/tlon-mobile/src/utils/notifications.ts diff --git a/apps/tlon-mobile/src/App.tsx b/apps/tlon-mobile/src/App.tsx index 871c0bddac..97784fc3e4 100644 --- a/apps/tlon-mobile/src/App.tsx +++ b/apps/tlon-mobile/src/App.tsx @@ -6,8 +6,6 @@ import { } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { TamaguiProvider } from '@tloncorp/ui'; -import type { Subscription } from 'expo-notifications'; -import { addNotificationResponseReceivedListener } from 'expo-notifications'; import { PostHogProvider } from 'posthog-react-native'; import { useEffect, useState } from 'react'; import { StatusBar, Text, View } from 'react-native'; @@ -58,22 +56,9 @@ const App = ({ wer }: Props) => { const screenOptions = useScreenOptions(); useEffect(() => { - let notificationTapListener: Subscription | undefined; if (isAuthenticated) { - // Start notification tap listener - // This only seems to get triggered on iOS. Android handles the tap and other intents in native code. - notificationTapListener = addNotificationResponseReceivedListener( - handleNotificationResponse - ); - - connectNotifications(); syncContacts(); } - - return () => { - // Clean up listeners - notificationTapListener?.remove(); - }; }, [isAuthenticated]); useEffect(() => { diff --git a/apps/tlon-mobile/src/utils/notifications.ts b/apps/tlon-mobile/src/utils/notifications.ts deleted file mode 100644 index d5aa3d9955..0000000000 --- a/apps/tlon-mobile/src/utils/notifications.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { NotificationResponse } from 'expo-notifications'; - -import { markChatRead } from '../lib/chatApi'; - -export const handleNotificationResponse = (response: NotificationResponse) => { - const { - actionIdentifier, - userText, - notification: { - request: { - content: { data }, - }, - }, - } = response; - if (actionIdentifier === 'markAsRead' && data.channelId) { - markChatRead(data.channelId); - } else if (actionIdentifier === 'reply' && userText) { - // Send reply - } else if (data.wer) { - // TODO: handle wer - // setUri((curr) => ({ - // ...curr, - // uri: createUri(shipUrl, data.wer), - // key: curr.key + 1, - // })); - } -};