init static method

Future init()

Implementation

static Future init() async {
  if (Platform.isAndroid) {
    FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
        FlutterLocalNotificationsPlugin();
    flutterLocalNotificationsPlugin
        .resolvePlatformSpecificImplementation<
            AndroidFlutterLocalNotificationsPlugin>()!
        .requestNotificationsPermission();
  }
  var android = const AndroidInitializationSettings('@mipmap/ic_launcher');
  var iOS = const DarwinInitializationSettings();
  var initSetttings = InitializationSettings(android: android, iOS: iOS);
  _flutterLocalNotificationsPlugin.initialize(
    initSetttings,
    onDidReceiveNotificationResponse: (notificationResponse) {
      switch (notificationResponse.notificationResponseType) {
        case NotificationResponseType.selectedNotification:
          var payload = NoticePayload.fromJson(notificationResponse.payload);
          var path = payload.path;
          debugPrint(path);
          break;
        case NotificationResponseType.selectedNotificationAction:
          break;
      }
    },
  ).then((value) {
    AppLog.i("初始化通知成功");
  });
}