componentDidMount() { if (this.props.LinkingActionMap) { Linking.getInitialURL().then(this._handleOpenURL.bind(this)); Platform.OS === 'ios' && Linking.addEventListener('url', this._handleOpenURLEvent); } if (this.props.persistenceKey) { AsyncStorage.getItem(this.props.persistenceKey, (err, storedString) => { if (err || !storedString) { this.setState({ navState: this.props.reducer(null, this.props.initialAction), }); return; } this.setState({ navState: JSON.parse(storedString), }); }); } }
componentDidMount() { Linking.getInitialURL().then((url) => { AsyncStorage.getItem('UIExplorerAppState', (err, storedString) => { const exampleAction = URIActionMap(this.props.exampleFromAppetizeParams); const urlAction = URIActionMap(url); const launchAction = exampleAction || urlAction; if (err || !storedString) { const initialAction = launchAction || {type: 'InitialAction'}; this.setState(UIExplorerNavigationReducer(null, initialAction)); return; } const storedState = JSON.parse(storedString); if (launchAction) { this.setState(UIExplorerNavigationReducer(storedState, launchAction)); return; } this.setState(storedState); }); }); Linking.addEventListener('url', (url) => { this._handleAction(URIActionMap(url)); }); }
/** * Add a handler to LinkingIOS changes by listening to the `url` event type * and providing the handler * * @deprecated */ static addEventListener(type: string, handler: Function) { console.warn('"LinkingIOS.addEventListener" is deprecated. Use "Linking.addEventListener" instead.'); Linking.addEventListener(type, handler); }