Teaks and start deeplink parsing

This commit is contained in:
Adolfo Reyna
2023-03-10 20:30:48 -06:00
parent 21f987a5a5
commit 3f44076709
5 changed files with 69 additions and 8 deletions

41
App.js
View File

@@ -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 }) => (
<MaterialIcons name="add" color="#fff" size={26} />
tabBarIcon: ({ color, route }) => (
<MaterialIcons name={true !== "NewPost" ? "add" : "send"} color="#fff" size={26} />
),
tabBarButton: (props) => (
<TouchableOpacity
@@ -194,6 +215,18 @@ const MainNavigation = () => {
),
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});
}
},
})}
/>
<Tab.Screen
name="Courses"