提交 e8986362 authored 作者: vipcxj's avatar vipcxj

fix: 捕捉code-push同步异常

add: 尝试处理任何异常
上级 8de6e36c
import { AsyncStorage } from 'react-native';
import { NavigationActions } from 'react-navigation';
import codePush from 'react-native-code-push';
export default {
namespace: 'welcome',
......@@ -7,6 +8,11 @@ export default {
reducers: {},
effects: {
*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');
if (!token) {
yield put(NavigationActions.navigate({
......
......@@ -2,7 +2,6 @@ import React, { PureComponent } from 'react';
import { BackHandler, Animated, Easing } from 'react-native';
import { StackNavigator, addNavigationHelpers, NavigationActions } from 'react-navigation';
import { connect } from 'react-redux';
import codePush from 'react-native-code-push';
import NavigatorService from './services/navigator';
import Welcome from './routes/welcome';
import Error from './routes/error';
......@@ -66,12 +65,6 @@ class Router extends PureComponent {
componentWillMount() {
BackHandler.addEventListener('hardwareBackPress', this.backHandle);
}
componentDidMount() {
codePush.sync();
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.backHandle);
}
......
......@@ -31,6 +31,8 @@ export function processError(err) {
default:
showError(err);
}
} else {
showError(err);
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论