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 GlobalState from './contexts/GlobalState.js';
|
||||||
import NewGroup from './Views/NewGroup.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 Tab = createBottomTabNavigator();
|
||||||
const Stack = createNativeStackNavigator();
|
const Stack = createNativeStackNavigator();
|
||||||
@@ -72,7 +92,7 @@ async function registerForPushNotificationsAsync() {
|
|||||||
finalStatus = status;
|
finalStatus = status;
|
||||||
}
|
}
|
||||||
if (finalStatus !== 'granted') {
|
if (finalStatus !== 'granted') {
|
||||||
alert('Failed to get push token for push notification!');
|
//alert('Failed to get push token for push notification!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
token = (await Notifications.getExpoPushTokenAsync({ projectId: "c2bb4d4e-4d4d-4f34-a873-7cad78c6023c", })).data;
|
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 gState = useSnapshot(GlobalState);
|
||||||
const viewer = gState.me;
|
const viewer = gState.me;
|
||||||
const [expoPushToken, setExpoPushToken] = useState('');
|
const [expoPushToken, setExpoPushToken] = useState('');
|
||||||
@@ -99,6 +119,7 @@ const MainNavigation = () => {
|
|||||||
API.registerToken(token);
|
API.registerToken(token);
|
||||||
return setExpoPushToken(token);
|
return setExpoPushToken(token);
|
||||||
});
|
});
|
||||||
|
checkDeepLinking();
|
||||||
|
|
||||||
// This listener is fired whenever a notification is received while the app is foregrounded
|
// This listener is fired whenever a notification is received while the app is foregrounded
|
||||||
notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
|
notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
|
||||||
@@ -170,8 +191,8 @@ const MainNavigation = () => {
|
|||||||
component={NewPostView}
|
component={NewPostView}
|
||||||
options={{
|
options={{
|
||||||
tabBarLabel: '',//i18n.t('message.statusUpdate'),
|
tabBarLabel: '',//i18n.t('message.statusUpdate'),
|
||||||
tabBarIcon: ({ color }) => (
|
tabBarIcon: ({ color, route }) => (
|
||||||
<MaterialIcons name="add" color="#fff" size={26} />
|
<MaterialIcons name={true !== "NewPost" ? "add" : "send"} color="#fff" size={26} />
|
||||||
),
|
),
|
||||||
tabBarButton: (props) => (
|
tabBarButton: (props) => (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -194,6 +215,18 @@ const MainNavigation = () => {
|
|||||||
),
|
),
|
||||||
header: () => { <></> },
|
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
|
<Tab.Screen
|
||||||
name="Courses"
|
name="Courses"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ let NewPostView = (props) => {
|
|||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log(props)
|
||||||
let subscribed = true;
|
let subscribed = true;
|
||||||
const getProfileData = async () => {
|
const getProfileData = async () => {
|
||||||
if (!props.route.params?.toProfile) return 0;
|
if (!props.route.params?.toProfile) return 0;
|
||||||
@@ -24,12 +25,16 @@ let NewPostView = (props) => {
|
|||||||
if (!subscribed) return 0;
|
if (!subscribed) return 0;
|
||||||
setToProfile(profileObj);
|
setToProfile(profileObj);
|
||||||
});
|
});
|
||||||
|
if(props.route.params?.sendNow){
|
||||||
|
console.log("sending from tab bar button")
|
||||||
|
await handleNewPostButton()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
getProfileData();
|
getProfileData();
|
||||||
return () => {
|
return () => {
|
||||||
subscribed = false;
|
subscribed = false;
|
||||||
}
|
}
|
||||||
}, []);
|
}, [props.route.params?.sendNow]);
|
||||||
|
|
||||||
const pickImage = async () => {
|
const pickImage = async () => {
|
||||||
// No permissions request is necessary for launching the image library
|
// No permissions request is necessary for launching the image library
|
||||||
|
|||||||
11
eas.json
11
eas.json
@@ -10,9 +10,16 @@
|
|||||||
"preview": {
|
"preview": {
|
||||||
"distribution": "internal"
|
"distribution": "internal"
|
||||||
},
|
},
|
||||||
"production": {}
|
"production": {},
|
||||||
|
"development-simulator": {
|
||||||
|
"developmentClient": true,
|
||||||
|
"distribution": "internal",
|
||||||
|
"ios": {
|
||||||
|
"simulator": true
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"submit": {
|
"submit": {
|
||||||
"production": {}
|
"production": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
15
package-lock.json
generated
15
package-lock.json
generated
@@ -9,6 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-async-storage/async-storage": "~1.17.3",
|
"@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/bottom-tabs": "^6.2.0",
|
||||||
"@react-navigation/native": "^6.0.8",
|
"@react-navigation/native": "^6.0.8",
|
||||||
"@react-navigation/native-stack": "^6.5.0",
|
"@react-navigation/native-stack": "^6.5.0",
|
||||||
@@ -4379,6 +4380,14 @@
|
|||||||
"node": ">=8"
|
"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": {
|
"node_modules/@react-native/assets": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz",
|
||||||
@@ -16378,6 +16387,12 @@
|
|||||||
"joi": "^17.2.1"
|
"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": {
|
"@react-native/assets": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz",
|
"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-vector-icons": "^9.1.0",
|
||||||
"react-native-web": "~0.18.7",
|
"react-native-web": "~0.18.7",
|
||||||
"react-native-webview": "11.23.1",
|
"react-native-webview": "11.23.1",
|
||||||
"valtio": "^1.4.0"
|
"valtio": "^1.4.0",
|
||||||
|
"@react-native-community/netinfo": "9.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.19.3"
|
"@babel/core": "^7.19.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user