极光推送方法拆分

This commit is contained in:
Daisy 2024-05-29 17:31:55 +08:00
parent cd2686d1d6
commit 6db55c8e37

View File

@ -29,22 +29,34 @@ class XSJPushProvider {
debug: true,
);
jpush.addEventHandler(
onReceiveNotification: (Map<String, dynamic> message) async {
AppLog.log('flutter onReceiveNotification: $message');
},
onOpenNotification: (Map<String, dynamic> message) async {
AppLog.log('flutter onOpenNotification: $message');
},
onReceiveMessage: (Map<String, dynamic> 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<String, dynamic> message) async {
AppLog.log('onReceiveNotification: $message');
},
onOpenNotification: (Map<String, dynamic> message) async {
AppLog.log('onOpenNotification: $message');
},
onReceiveMessage: (Map<String, dynamic> message) async {
AppLog.log('onReceiveMessage: $message');
},
onReceiveNotificationAuthorization: (Map<String, dynamic> message) async {
AppLog.log('onReceiveNotificationAuthorization: $message');
},
);
}
//ID
Future<void> bindDeviceID() async {
try {
AppLog.log('Fetching registration ID...');
final String rid = await jpush.getRegistrationID();