Teaks and start deeplink parsing
This commit is contained in:
41
App.js
41
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 }) => (
|
||||
<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"
|
||||
|
||||
@@ -17,6 +17,7 @@ let NewPostView = (props) => {
|
||||
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
|
||||
|
||||
11
eas.json
11
eas.json
@@ -10,9 +10,16 @@
|
||||
"preview": {
|
||||
"distribution": "internal"
|
||||
},
|
||||
"production": {}
|
||||
"production": {},
|
||||
"development-simulator": {
|
||||
"developmentClient": true,
|
||||
"distribution": "internal",
|
||||
"ios": {
|
||||
"simulator": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"submit": {
|
||||
"production": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
package-lock.json
generated
15
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user