How to use the jpush-react-native.addReceiveCustomMsgListener function in jpush-react-native

To help you get started, we’ve selected a few jpush-react-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jpush / jpush-react-native / react-native-android / push_activity.js View on Github external
componentDidMount() {
    JPushModule.addReceiveCustomMsgListener((message) => {
      this.setState({pushMsg: message});
    });
    JPushModule.addReceiveNotificationListener((map) => {
      console.log("alertContent: " + map.alertContent);
      console.log("extras: " + map.extras);
      // var extra = JSON.parse(map.extras);
      // console.log(extra.key + ": " + extra.value);
    });
    JPushModule.addReceiveOpenNotificationListener((map) => {
      console.log("Opening notification!");
      this.props.navigator.push({name: "pushActivity"});
    })
  }
github duheng / Mozi / src / AppNavigationState.js View on Github external
componentDidMount() {
    if (Platform.OS === 'android') {
      // 通知 JPushModule 初始化完成,发送缓存事件。
      JPushModule.notifyJSDidLoad(() => {});
    } else {
      JPushModule.initPush();
    }

    // 接收自定义消息
    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');
    });
  }
github jpush / jpush-react-native / example / react-native-android / push_activity.js View on Github external
componentDidMount() {
		JPushModule.getInfo((map) => {
			this.setState({
				appkey: map.myAppKey,
				imei: map.myImei,
				package: map.myPackageName,
				deviceId: map.myDeviceId,
				version: map.myVersion
			});
		});
		JPushModule.notifyJSDidLoad((resultCode) => {
			if (resultCode === 0) { }
		});
		JPushModule.addReceiveCustomMsgListener((map) => {
			this.setState({
				pushMsg: map.message
			});
			console.log("extras: " + map.extras);
		});
		JPushModule.addReceiveNotificationListener((map) => {
			console.log("alertContent: " + map.alertContent);
			console.log("extras: " + map.extras);
			// var extra = JSON.parse(map.extras);
			// console.log(extra.key + ": " + extra.value);
		});
		JPushModule.addReceiveOpenNotificationListener((map) => {
			console.log("Opening notification!");
			console.log("map.extra: " + map.extras);
			this.jumpSecondActivity();
			// JPushModule.jumpToPushActivity("SecondActivity");
github jiasongs / cnodeRN / index.android.js View on Github external
global.console = {
    info: () => { },
    log: () => { },
    warn: () => { },
    debug: () => { },
    error: () => { }
  };
} else {
  console.log("kaifa");
}

JPushModule.notifyJSDidLoad((resultCode) => {
  console.log(resultCode)
  if (resultCode === 0) { console.log('success') }
});
JPushModule.addReceiveCustomMsgListener((map) => {
  console.log("extras: " + map.extras);
});
JPushModule.addReceiveNotificationListener((map) => {
  console.log("alertContent: " + map.alertContent);
  console.log("extras: " + map.extras);
  // var extra = JSON.parse(map.extras);
  // console.log(extra.key + ": " + extra.value);
});
JPushModule.addReceiveOpenNotificationListener((map) => {
  console.log("Opening notification!");
  console.log("map.extra: " + map.extras);
  // JPushModule.jumpToPushActivity("SecondActivity");
});
JPushModule.addGetRegistrationIdListener((registrationId) => {
  console.log("Device register succeed, registrationId " + registrationId);
});
github CodeRabbitYu / ShiTu / app / pages / ShiTu / ShiTu.js View on Github external
//     // console.log(extra.key + ": " + extra.value);
        // });


        // Request.get(Config.api.test.test,(data)=>{
        //     console.log(data);
        // },(error)=>{
        //     console.log(error);
        // });

        if (Android){
            BackHandler.addEventListener('handwareBackPress',this.onBackAndroid)
        }


        JPushModule.addReceiveCustomMsgListener((message) => {
            console.log(message);
            //这是默认的通知消息
            alert(message.alertContent);
            // this.setState({pushMsg:message});

        });

        JPushModule.addReceiveOpenNotificationListener((message)=>{
            console.log(message);
            alert(message.alertContent);
        })


        // console.log(this.props.ShiTuReducer);

        // NetWorkTool.checkNetworkState((isConnected)=>{
github ok406lhq / RTCoin / src / root.js View on Github external
componentDidMount() {
        SplashScreen.hide(); // 隐藏启动屏
        // 新版本必需写回调函数
        // JPushModule.notifyJSDidLoad();
        JPushModule.notifyJSDidLoad((resultCode) => {
            if (resultCode === 0) {
            }
        });

        // 接收自定义消息
        JPushModule.addReceiveCustomMsgListener((message) => {
            this.setState({pushMsg: message});
        });
        // 接收推送通知
        JPushModule.addReceiveNotificationListener((message) => {
            console.log("receive notification: " + message);
        });
        // 打开通知
        JPushModule.addReceiveOpenNotificationListener((map) => {
            console.log("Opening notification!");
            console.log("map.extra: " + map.extras);
            // 可执行跳转操作,也可跳转原生页面
            // this.props.navigation.navigate("SecondActivity");
        });
    }