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();