Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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);
});
const store = configureStore();
export default class cnodeRN extends Component {
render() {
return (
);
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");
});
JPushModule.addGetRegistrationIdListener((registrationId) => {
console.log("Device register succeed, registrationId " + registrationId);
});
// var notification = {
// buildId: 1,
// id: 5,
// title: 'jpush',
// content: 'This is a test!!!!',
// extra: {
// key1: 'value1',
// key2: 'value2'
// 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");
});
}
_jpushCommonEvent() {
if (Platform.OS == "ios") {
JPushModule.setBadge(0, success => {});
}
JPushModule.addReceiveOpenNotificationListener(map => {
// console.log("map-------------jpush", map);
if (typeof map.extras["type"] != "undefined") {
switch (map.extras.type) {
case jpushCommonUrlDefined.url:
{
this.props.navigation.navigate("Content", {
data: map.extras,
kind: "jpush"
});
}
break;
case jpushCommonUrlDefined.schema:
{
const {schema, type, ...rest} = map.extras;
this.props.navigation.navigate(!!map.extras.schema ? map.extras.schema : "Food", rest);
}
// });
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)=>{
// console.log(isConnected);
// });
};
// 设置android端监听
JPushModule.notifyJSDidLoad(resultCode => {
if (resultCode === 0) {
console.log("设置监听成功");
}
JPushModule.addGetRegistrationIdListener((registrationId) => {
console.log("设备注册成功,registrationId: " + registrationId);
});
});
}
JPushModule.addReceiveNotificationListener((map) => {
console.log("收到推送消息");
console.log(map);
// TODO: 处理通知消息
});
JPushModule.addReceiveOpenNotificationListener((map) => {
console.log("监听到点击通知的事件");
console.log(map);
// TODO: 跳转界面
});
}
// 通知 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');
});
}
if (resultCode === 0) { console.log('success') }
});
}
JPushModule.addnetworkDidLoginListener(() => {
console.log('连接已登录')
JPushModule.setBadge(0, (success) => { console.log('setBadge:' + success) });
// JPushModule.addTags(['dasffas'], (result) => {
// Alert.alert('addTags success:' + JSON.stringify(result))
// })
})
JPushModule.addOpenNotificationLaunchAppListener((result) => {
//
Alert.alert('addOpenNotificationLaunchAppListener', 'the notification is :' + JSON.stringify(result))
})
JPushModule.addReceiveOpenNotificationListener((result) => {
// 点击通知栏进入
JPushModule.setBadge(0, (success) => { console.log('setBadge:' + success) });
console.log('1111')
Alert.alert('addReceiveOpenNotificationListener', JSON.stringify(result))
})
JPushModule.addReceiveNotificationListener((result) => {
// 收到远程通知
Alert.alert('addReceiveNotificationListener', JSON.stringify(result))
})
JPushModule.addConnectionChangeListener((result) => {
if (result) {
console.log('网络已连接')
} else {
console.log('网络已断开')
componentWillMount() {
JPushModule.setupPush() // if you add register notification in Appdelegate.m 有 don't need call this function
JPushModule.getBadge((badge) => {Alert.alert("badge", badge)})
JPushModule.addnetworkDidLoginListener(() => {
console.log('连接已登录')
JPushModule.addTags(['dasffas'], (result)=> {
Alert.alert('addTags success:' + JSON.stringify(result))
})
})
JPushModule.addOpenNotificationLaunchAppListener((result) => {
Alert.alert('addOpenNotificationLaunchAppListener', 'the notification is :' + JSON.stringify(result))
})
JPushModule.addReceiveOpenNotificationListener((result) => {
Alert.alert('addReceiveOpenNotificationListener',JSON.stringify(result))
})
JPushModule.addReceiveNotificationListener((result) => {
Alert.alert('addReceiveNotificationListener',JSON.stringify(result))
})
JPushModule.addConnectionChangeListener((result) => {
if (result) {
console.log('网络已连接')
} else {
console.log('网络已断开')
}
})
// JPushModule.addReceiveNotificationListener((notification) => {
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');
});
}