Good Evening, I am trying to use Deeplinking so when I pass in a flow_id(meditation) it will match it to the proper flow_key (firestore) and open the proper meditation screen based on the match. Unfortunately I am not getting to the first step in my conditional because flow_key is returning undefined. I am not sure what I am doing. I did log out URL and it returns a very large object.
import React, { useEffect } from 'react'; import { Linking, View, Text } from 'react-native'; import { Actions } from 'react-native-router-flux'; import { useSelector, useDispatch } from 'react-redux'; import Router from '../Router'; import reducers from '../reducers'; import * as ActionCreators from '../actions'; import * as Globals from '../library/utils/globals'; import { selectFlow, flowsFetch, subFlowsFetch, receivedNotification } from '../actions'; const DeepLink = (props) => { const dispatch = useDispatch(); const app_bootstrap_completed = useSelector((state) => state.app_bootstrap); function testNew(url) { console.log('[DeepLink] onDeepLink: ', url); if (app_bootstrap_completed.completed) { console.log('[DeepLink] bootstrap completed!'); Actions.reset('mainTabs'); console.log('[DeepLink] flow key: ', url.flow_key); // Check if Deepline is a defined flow if (props.flow_id == url.flow_key && url.flow_key !== undefined) { const allFlows = useSelector((state) => state.flows.all); const flow = allFlows.filter((obj) => { return obj.key === url.key; }); console.log('[DeepLink] # of flows with matching key in store: ', flow.length); // If no flows of matching key found, wait for database fetch if (flow.length == 0) { console.log('[DeepLink] flow not found locally; starting timer...'); dispatch(flowsFetch()); Actions.reset('notificationLoader', { parameters: url }); // Timer to wait for update to flows setTimeout(() => { // Check for flows in updated store const updatedAllFlows = allFlows.getState().flows.all; const updatedFlow = updatedAllFlows.filter((obj, index) => { return obj.key === url.flow_key; }); // If flow still not found, go home if (updatedFlow.length == 0) { console.log('[DeepLink] desired flow still not found; returning to home screen'); Actions.reset('mainTabs'); } else { console.log('[DeepLink] timer ended -- flow successfully fetched!'); } }, 5000); } else { console.log('[DeepLink] flow found locally!'); // Go to selected flow dispatch(selectFlow(flow[0])); dispatch(subFlowsFetch(flow[0].flow_key, (sub_flows) => { Actions.flowDescription({ flowCategory: flow[0].flow_categories, title: flow[0].label, duration: url.duration, imageUri: flow[0].image_uri, lock: url.lock, dynamicPacingSupport: url.dynamic_pacing_support, choiceSupport: url.choice_support, sub_flows, flow: flow[0], }); })); } // Check if DeepLink is an undefined flow } else if (url.flow_key === undefined) { console.log('[DeepLink] Error: flow key is undefined'); console.log(url); // DeepLink is not a flow } } else { console.log('[DeepLink] bootstrap not completed!'); } } // Handle DeepLink return ( <View> <Text onPress={testNew}> {props.flow_id} </Text> </View> ); }; export default DeepLink;
没有评论:
发表评论