提交 4c261e15 authored 作者: 吴强's avatar 吴强
import { AsyncStorage } from 'react-native'; import { AsyncStorage } from 'react-native';
import { NavigationActions } from 'react-navigation'; import { NavigationActions } from 'react-navigation';
import codePush from 'react-native-code-push';
export default { export default {
namespace: 'welcome', namespace: 'welcome',
...@@ -7,6 +8,11 @@ export default { ...@@ -7,6 +8,11 @@ export default {
reducers: {}, reducers: {},
effects: { effects: {
*init(ignored, { put, call }) { *init(ignored, { put, call }) {
try {
yield call(codePush.sync);
} catch (e) {
console.error(e); // eslint-disable-line no-console
}
const token = yield call(AsyncStorage.getItem, 'token'); const token = yield call(AsyncStorage.getItem, 'token');
if (!token) { if (!token) {
yield put(NavigationActions.navigate({ yield put(NavigationActions.navigate({
......
...@@ -2,7 +2,6 @@ import React, { PureComponent } from 'react'; ...@@ -2,7 +2,6 @@ import React, { PureComponent } from 'react';
import { BackHandler, Animated, Easing } from 'react-native'; import { BackHandler, Animated, Easing } from 'react-native';
import { StackNavigator, addNavigationHelpers, NavigationActions } from 'react-navigation'; import { StackNavigator, addNavigationHelpers, NavigationActions } from 'react-navigation';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import codePush from 'react-native-code-push';
import NavigatorService from './services/navigator'; import NavigatorService from './services/navigator';
import Welcome from './routes/welcome'; import Welcome from './routes/welcome';
import Error from './routes/error'; import Error from './routes/error';
...@@ -66,12 +65,6 @@ class Router extends PureComponent { ...@@ -66,12 +65,6 @@ class Router extends PureComponent {
componentWillMount() { componentWillMount() {
BackHandler.addEventListener('hardwareBackPress', this.backHandle); BackHandler.addEventListener('hardwareBackPress', this.backHandle);
} }
componentDidMount() {
codePush.sync();
}
componentWillUnmount() { componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.backHandle); BackHandler.removeEventListener('hardwareBackPress', this.backHandle);
} }
......
...@@ -33,6 +33,8 @@ export function processError(err) { ...@@ -33,6 +33,8 @@ export function processError(err) {
default: default:
showError(err); showError(err);
} }
} else {
showError(err);
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论