【发布时间】:2016-03-09 09:39:57
【问题描述】:
我在 react-native android 中使用BackAndroid。当我从主页移动到下一页并返回主页时它工作正常,但如果我按下它后它不会退出应用程序。
这是我的代码:
componentWillMount: function(){
let context = this
if (Platform.OS !== 'ios') {
BackAndroid.addEventListener('hardwareBackPress', context.backAndroidHandler);
}
},
componentWillUnmount: function(){
let context = this
var Meteor = context.props.value.DDPClient;
// TODO Unsuscribe is not a valid function
Meteor.unsuscribe(subscriptionId);
context.props.value.setCurrentConversationID(null);
if (Platform.OS !== 'ios') {
BackAndroid.removeEventListener('hardwareBackPress', context.backAndroidHandler);
}
},
backAndroidHandler: function(){
// console.log('hardwareBackPress');
this.props.navigator.pop();
return true;
},
【问题讨论】:
标签: javascript android reactjs react-native