From 6db55c8e378ad4cd6e372261584147faeb8a854b Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 29 May 2024 17:31:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=81=E5=85=89=E6=8E=A8=E9=80=81=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools/xs_jPhush.dart | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/tools/xs_jPhush.dart b/lib/tools/xs_jPhush.dart index fb3f9eec..986243e7 100755 --- a/lib/tools/xs_jPhush.dart +++ b/lib/tools/xs_jPhush.dart @@ -29,22 +29,34 @@ class XSJPushProvider { debug: true, ); - jpush.addEventHandler( - onReceiveNotification: (Map message) async { - AppLog.log('flutter onReceiveNotification: $message'); - }, - onOpenNotification: (Map message) async { - AppLog.log('flutter onOpenNotification: $message'); - }, - onReceiveMessage: (Map message) async { - AppLog.log('flutter onReceiveMessage: $message'); - }, - ); - jpush.applyPushAuthority( const NotificationSettingsIOS(sound: true, alert: true, badge: false), ); + addJPushEventHandler(); + bindDeviceID(); + } + + //极光推送事件处理方法 + void addJPushEventHandler() { + jpush.addEventHandler( + onReceiveNotification: (Map message) async { + AppLog.log('onReceiveNotification: $message'); + }, + onOpenNotification: (Map message) async { + AppLog.log('onOpenNotification: $message'); + }, + onReceiveMessage: (Map message) async { + AppLog.log('onReceiveMessage: $message'); + }, + onReceiveNotificationAuthorization: (Map message) async { + AppLog.log('onReceiveNotificationAuthorization: $message'); + }, + ); + } + + //绑定设备ID + Future bindDeviceID() async { try { AppLog.log('Fetching registration ID...'); final String rid = await jpush.getRegistrationID();