diff --git a/App.js b/App.js index 799526f..a6dd67b 100644 --- a/App.js +++ b/App.js @@ -27,6 +27,26 @@ import { useSnapshot } from 'valtio'; import GlobalState from './contexts/GlobalState.js'; import NewGroup from './Views/NewGroup.js'; +import { Linking } from 'expo'; + +const handleDeepLink = (url) => { + // Handle the deep linking URL here + alert('Deep link:', url); +} + +const checkDeepLinking = async () => { + // Check if the app was opened by a deep linking URL + const initialUrl = await Linking.getInitialURL(); + if (initialUrl) { + handleDeepLink(initialUrl); + } + + // Add an event listener to handle deep linking URLs + Linking.addEventListener('url', (event) => { + handleDeepLink(event.url); + }); +} + const Tab = createBottomTabNavigator(); const Stack = createNativeStackNavigator(); @@ -72,7 +92,7 @@ async function registerForPushNotificationsAsync() { finalStatus = status; } if (finalStatus !== 'granted') { - alert('Failed to get push token for push notification!'); + //alert('Failed to get push token for push notification!'); return; } token = (await Notifications.getExpoPushTokenAsync({ projectId: "c2bb4d4e-4d4d-4f34-a873-7cad78c6023c", })).data; @@ -84,7 +104,7 @@ async function registerForPushNotificationsAsync() { -const MainNavigation = () => { +const MainNavigation = ({route}) => { const gState = useSnapshot(GlobalState); const viewer = gState.me; const [expoPushToken, setExpoPushToken] = useState(''); @@ -99,6 +119,7 @@ const MainNavigation = () => { API.registerToken(token); return setExpoPushToken(token); }); + checkDeepLinking(); // This listener is fired whenever a notification is received while the app is foregrounded notificationListener.current = Notifications.addNotificationReceivedListener(notification => { @@ -170,8 +191,8 @@ const MainNavigation = () => { component={NewPostView} options={{ tabBarLabel: '',//i18n.t('message.statusUpdate'), - tabBarIcon: ({ color }) => ( - + tabBarIcon: ({ color, route }) => ( + ), tabBarButton: (props) => ( { ), header: () => { <> }, }} + listeners={({ navigation, route }) => ({ + tabPress: e => { + //console.log("listener", route) + if(route.name !== "NewPost"){ + // Target current profile if one in route + navigation.navigate('NewPost', {toProfile: route.params?.profileid}); + } else { + //Send function on child + navigation.navigate('NewPost', {toProfile: route.params?.profileid, sendNow: true}); + } + }, + })} /> { const navigation = useNavigation(); useEffect(() => { + console.log(props) let subscribed = true; const getProfileData = async () => { if (!props.route.params?.toProfile) return 0; @@ -24,12 +25,16 @@ let NewPostView = (props) => { if (!subscribed) return 0; setToProfile(profileObj); }); + if(props.route.params?.sendNow){ + console.log("sending from tab bar button") + await handleNewPostButton() + } }; getProfileData(); return () => { subscribed = false; } - }, []); + }, [props.route.params?.sendNow]); const pickImage = async () => { // No permissions request is necessary for launching the image library diff --git a/eas.json b/eas.json index 7a6f4b0..d9f0e3c 100644 --- a/eas.json +++ b/eas.json @@ -10,9 +10,16 @@ "preview": { "distribution": "internal" }, - "production": {} + "production": {}, + "development-simulator": { + "developmentClient": true, + "distribution": "internal", + "ios": { + "simulator": true + } + } }, "submit": { "production": {} } -} +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6d26d39..2c68666 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "dependencies": { "@react-native-async-storage/async-storage": "~1.17.3", + "@react-native-community/netinfo": "9.3.5", "@react-navigation/bottom-tabs": "^6.2.0", "@react-navigation/native": "^6.0.8", "@react-navigation/native-stack": "^6.5.0", @@ -4379,6 +4380,14 @@ "node": ">=8" } }, + "node_modules/@react-native-community/netinfo": { + "version": "9.3.5", + "resolved": "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-9.3.5.tgz", + "integrity": "sha512-Mqbh/J8YCfc+EqSjq5OJn2USmcD8On4048pKEfyCsCDty3lQs1SNcmHqJdu9idNU2v//aM73T8F+re59cf78Ig==", + "peerDependencies": { + "react-native": ">=0.59" + } + }, "node_modules/@react-native/assets": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz", @@ -16378,6 +16387,12 @@ "joi": "^17.2.1" } }, + "@react-native-community/netinfo": { + "version": "9.3.5", + "resolved": "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-9.3.5.tgz", + "integrity": "sha512-Mqbh/J8YCfc+EqSjq5OJn2USmcD8On4048pKEfyCsCDty3lQs1SNcmHqJdu9idNU2v//aM73T8F+re59cf78Ig==", + "requires": {} + }, "@react-native/assets": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz", diff --git a/package.json b/package.json index 6abbdab..65368fc 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "react-native-vector-icons": "^9.1.0", "react-native-web": "~0.18.7", "react-native-webview": "11.23.1", - "valtio": "^1.4.0" + "valtio": "^1.4.0", + "@react-native-community/netinfo": "9.3.5" }, "devDependencies": { "@babel/core": "^7.19.3"