<commit_before>import React, { Component, } from 'react';
import { BackHandler, ToastAndroid, } from 'react-native';
import { connect, } from 'react-redux';
import { NavigationActions, } from 'react-navigation';
import JPushModule from 'jpush-react-native';
import Routers from './routers/app';

@connect(state => ({ nav: state.nav, }))
export default class AppNavigationState extends Component {
  componentDidMount() {
    JPushModule.notifyJSDidLoad((resultCode) => {
      if (resultCode === 0) { }
    });
    // 接收自定义消息
    JPushModule.addReceiveCustomMsgListener(message => {
      this.setState({ pushMsg: message, });
    });
    // 接收推送通知
    JPushModule.addReceiveNotificationListener(message => {
      console.log(`receive notification: ${message}`);
    });
    // 打开通知
    JPushModule.addReceiveOpenNotificationListener(() => {
      console.log('Opening notification!');
      //! !this.root && this.root.props.navigation.navigate('Gong');
    });
    BackHandler.addEventListener('hardwareBackPress', this.onBackPress);
  }

  componentWillUnmount() {
    JPushModule.clearAllNotifications();
    BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
    this.lastBackPressed = null;

    //  JPushModule.removeReceiveCustomMsgListener();
    // JPushModule.removeReceiveNotificationListener();<commit_msg>极光推送安卓bug<commit_after>import React, { Component, } from 'react';
import { BackHandler, ToastAndroid, Platform, } from 'react-native';
import { connect, } from 'react-redux';
import { NavigationActions, } from 'react-navigation';
import JPushModule from 'jpush-react-native';
import Routers from './routers/app';

@connect(state => ({ nav: state.nav, }))
export default class AppNavigationState extends Component {
  componentDidMount() {
    if (Platform.OS === 'android') {
      // 通知 JPushModule 初始化完成，发送缓存事件。
      JPushModule.notifyJSDidLoad(() => {});
    }

    JPushModule.getLaunchAppNotification(notification => {
      if (notification === undefined) {
        // 说明应用不是通过点击通知启动的，是通过点击应用 icon
      } else if (notification.aps === undefined) {
        // 说明是 local notification
      } else {
        // 说明是 remote notification
      }
    });
    // 接收自定义消息
    JPushModule.addReceiveCustomMsgListener(message => {
      // this.setState({ pushMsg: message, });
    });
    // 接收推送通知
    JPushModule.addReceiveNotificationListener(message => {
      // console.log(`receive notification: ${message}`);
    });
    // 打开通知
    JPushModule.addReceiveOpenNotificationListener(() => {
      console.log('Opening notification!');
      !!this.root && this.root._navigation.navigate('Gong');
    });

    BackHandler.addEventListener('hardwareBackPress', this.onBackPress);
  }

  componentWillUnmount() {
    BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
    this.lastBackPressed = null;

    JPushModule.removeReceiveCustomMsgListener();
    JPushModule.removeReceiveNotificationListener();
    JPushModule.removeReceiveOpenNotificationListener();
    JPushModule.clearAllNotifications();
{'fraction_non_alphanumeric': 0.13609660574412533, 'fraction_numerical': 0.00032637075718015666, 'mean_word_length': 3.959546925566343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2068559', 'n_tokens_mistral': 928, 'n_tokens_neox': 929, 'n_words': 153}