React Native 页面实现通知监听事件

1. 只在React Native页面里发送和接受消息

A页面:

import {DeviceEventEmitter} from 'react-native'

componentDidMount(){

     this.subscription = DeviceEventEmitter.addListener('noticeName', Function);

}


componentWillUnmount(){

this.subscription.remove();

}

B页面:

import {DeviceEventEmitter} from 'react-native';

//post通知信息

DeviceEventEmitter.emit('noticeName', param);


2. 在ReactNative 项目中实现通知事件监听,在Native中实现转发机制

你可能感兴趣的:(React Native 页面实现通知监听事件)