123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <script>
- const jpushModule = uni.requireNativePlugin('JG-JPush')
- console.log(jpushModule.getRegistrationID,'jpushModule')
- export default {
- onLaunch: function() {
- console.log('App Launch')
- if (uni.getSystemInfoSync().platform == "ios") {
- // 请求定位权限
- let locationServicesEnabled = jpushModule.locationServicesEnabled()
- let locationAuthorizationStatus = jpushModule.getLocationAuthorizationStatus()
- console.log('locationAuthorizationStatus', locationAuthorizationStatus)
- if (locationServicesEnabled == true && locationAuthorizationStatus < 3) {
- jpushModule.requestLocationAuthorization((result) => {
- console.log('定位权限', result.status)
- })
- }
- jpushModule.requestNotificationAuthorization((result) => {
- let status = result.status
- if (status < 2) {
- uni.showToast({
- icon: 'none',
- title: '您还没有打开通知权限',
- duration: 3000
- })
- }
- })
- }
-
- jpushModule.getRegistrationID(result => {
- console.log(result,"注册ID.....")
- uni.showToast({
- title:result.registerID,
- icon:"success",
- duration:30000
- })
- })
-
-
- jpushModule.initJPushService();
- jpushModule.setLoggerEnable(true);
- jpushModule.addConnectEventListener(result => {
- console.log(result)
- let connectEnable = result.connectEnable
- uni.$emit('connectStatusChange', connectEnable)
- });
- jpushModule.addNotificationListener(result => {
- console.log(result)
- if (result.notificationEventType == "notificationOpened") {
- //点击窗口通知栏推送的消息 跳转指定页面
- uni.navigateTo({
- url: '/pages/home/warningCenter/warningCenter',
- complete(res) {
- console.log(res);
- }
- })
- }
- });
- jpushModule.addCustomMessageListener(result => {
- let type = result.type
- let messageType = result.messageType
- let content = result.content
- uni.showToast({
- icon: 'none',
- title: JSON.stringify(result),
- duration: 3000
- })
- })
- jpushModule.addLocalNotificationListener(result => {
- let messageID = result.messageID
- let title = result.title
- let content = result.content
- let extras = result.extras
- uni.showToast({
- icon: 'none',
- title: JSON.stringify(result),
- duration: 3000
- })
- })
- jpushModule.addGeofenceListener(result => {
- let code = result.code
- let type = result.type
- let geofenceId = result.geofenceId
- let userInfo = result.userInfo
- uni.showToast({
- icon: 'none',
- title: '触发地理围栏',
- duration: 3000
- })
- })
- jpushModule.setIsAllowedInMessagePop(true)
- jpushModule.pullInMessage(result => {
- let code = result.code
- console.log(code)
- })
- jpushModule.addInMessageListener(result => {
- let eventType = result.eventType
- let messageType = result.messageType
- let content = result.content
- console.log('inMessageListener', eventType, messageType, content)
- uni.showToast({
- icon: 'none',
- title: JSON.stringify(result),
- duration: 3000
- })
- })
- },
- onShow: function() {
- console.log('App Show')
- },
- onHide: function() {
- console.log('App Hide')
- }
- }
- </script>
- <style>
- /*每个页面公共css */
- </style>
|