import showAlert from '@/components/basic/Alert'; import { clientId } from '@/services/user'; import JPush from 'jpush-react-native'; import { title } from 'process'; import { uploadPermissions } from './native_permission_check'; export default function jgPush() { // const JPush = require('jpush-react-native') // debugger JPush.init({ appKey: "7cf918ada725a9e9aecc8a17", channel: "dev", production: false }); //连接状态 JPush.addConnectEventListener(result => { console.log(result) }) //通知回调 var notificationListener = result => { console.log("notificationListener:" + JSON.stringify(result)) // alert(JSON.stringify(result)) }; JPush.addNotificationListener(notificationListener); //本地通知回调 var localNotificationListener = result => { console.log("localNotificationListener:" + JSON.stringify(result)) }; JPush.addLocalNotificationListener(localNotificationListener); //自定义消息回调 var customMessageListener = result => { console.log("customMessageListener:" + JSON.stringify(result)) }; JPush.addCustomMessageListener(customMessageListener); //应用内消息回调 JPush.pageEnterTo("HomePage") // 进入首页,当页面退出时请调用 JPush.pageLeave('HomePage') var inappMessageListener = result => { console.log("inappMessageListener:" + JSON.stringify(result)) // alert(JSON.stringify(result)) }; JPush.addInappMessageListener(inappMessageListener); //tag alias事件回调 var tagAliasListener = result => { console.log("tagAliasListener:" + JSON.stringify(result)) }; JPush.addTagAliasListener(tagAliasListener); //手机号码事件回调 var mobileNumberListener = result => { console.log("mobileNumberListener:" + JSON.stringify(result)) }; JPush.addMobileNumberListener(mobileNumberListener); JPush.getRegistrationID(obj => { uploadPermissions() global.registerID = obj.registerID setTimeout(() => { clientId() }, 3000) }) }