当前位置: 首页 > news >正文

合肥市网站制作百度云建站

合肥市网站制作,百度云建站,长春做网站,网页版梦幻西游兑换码flutter_local_notifications 消息通知 flutter_local_notifications地址 flutter_local_notifications: ^18.0.1class NotificationHelper {//工厂模式调用该类时#xff0c;默认调用此方法#xff0c;将实例对象返回出去static NotificationHelper? _instance null;sta…flutter_local_notifications 消息通知 flutter_local_notifications地址 flutter_local_notifications: ^18.0.1class NotificationHelper {//工厂模式调用该类时默认调用此方法将实例对象返回出去static NotificationHelper? _instance null;static NotificationHelper getInstance() {_instance ?? NotificationHelper._initial();return _instance!;}factory NotificationHelper() _instance ?? NotificationHelper._initial();//创建命名构造函数NotificationHelper._initial() {initialize();}// FlutterLocalNotificationsPlugin实例final FlutterLocalNotificationsPlugin _notificationsPlugin FlutterLocalNotificationsPlugin();// 常量定义static const String _channelId your.channel.id;static const String _channelName your channel name;static const String _channelDescription your channel description;static const String _ticker ticker;static const String _darwinNotificationCategoryPlain plainCategory;// 初始化通知插件Futurevoid initialize() async {try {final AndroidInitializationSettings initializationSettingsAndroid AndroidInitializationSettings(mipmap/ic_launcher);final DarwinInitializationSettings initializationSettingsIOS DarwinInitializationSettings();final InitializationSettings initializationSettings InitializationSettings(android: initializationSettingsAndroid,iOS: initializationSettingsIOS);await _notificationsPlugin.initialize(initializationSettings);} catch (e) {print(初始化通知插件失败: $e);}}Futurevoid requestNotificationPermissions() async {if (await Permission.notification.isDenied) {final status await Permission.notification.request();final status1 await Permission.scheduleExactAlarm.request();LogUtils.d(requestNotificationPermissions 通知权限status1 $status1);if (status.isGranted) {LogUtils.d(requestNotificationPermissions 通知权限已授予);print(通知权限已授予);} else {LogUtils.d(requestNotificationPermissions 通知权限被拒绝);print(通知权限被拒绝);}} else {LogUtils.d(requestNotificationPermissions 通知权限已授予);print(通知权限已授予);}}// 显示通知Futurevoid showNotification({required String title, required String body}) async {try {final AndroidNotificationDetails androidNotificationDetails AndroidNotificationDetails(_channelId, _channelName,channelDescription: _channelDescription,importance: Importance.max,priority: Priority.high,ticker: _ticker);final DarwinNotificationDetails iosNotificationDetails DarwinNotificationDetails(categoryIdentifier: _darwinNotificationCategoryPlain);final NotificationDetails platformChannelSpecifics NotificationDetails(android: androidNotificationDetails, iOS: iosNotificationDetails);await _notificationsPlugin.show(1,title,body,platformChannelSpecifics,);} catch (e) {print(显示通知失败: $e);}}// 周期性通知Futurevoid scheduleNotification({required int id,required String title,required String body,}) async {const AndroidNotificationDetails androidNotificationDetails AndroidNotificationDetails(your.channel.id, your channel name,channelDescription: your channel description,importance: Importance.max,priority: Priority.high,ticker: ticker);// ios的通知const String darwinNotificationCategoryPlain plainCategory;const DarwinNotificationDetails iosNotificationDetails DarwinNotificationDetails(categoryIdentifier: darwinNotificationCategoryPlain, // 通知分类);// 创建跨平台通知const NotificationDetails platformChannelSpecifics NotificationDetails(android: androidNotificationDetails, iOS: iosNotificationDetails); // 发起通知await _notificationsPlugin.periodicallyShow(id, title, body, RepeatInterval.everyMinute, platformChannelSpecifics);}// 定时通知Futurevoid zonedScheduleNotification({required int id,required String title,required String body,required DateTime scheduledDateTime}) async {const AndroidNotificationDetails androidNotificationDetails AndroidNotificationDetails(10001, 唤醒,channelDescription: your channel description,importance: Importance.max,priority: Priority.high,ticker: ticker);// ios的通知const String darwinNotificationCategoryPlain plainCategory;const DarwinNotificationDetails iosNotificationDetails DarwinNotificationDetails(categoryIdentifier: darwinNotificationCategoryPlain, // 通知分类);// 创建跨平台通知const NotificationDetails platformChannelSpecifics NotificationDetails(android: androidNotificationDetails, iOS: iosNotificationDetails);// 获取本地时区final location tz.getLocation(tz.local.name);// 发起通知_notificationsPlugin.zonedSchedule(id, title, body,TZDateTime.from(scheduledDateTime, location), // 使用本地时区的时间platformChannelSpecifics,uiLocalNotificationDateInterpretation:UILocalNotificationDateInterpretation.wallClockTime, // 设置通知的触发时间是觉得时间);}/// 取消全部通知cancelAll(){_notificationsPlugin.cancelAll();}/// 取消对应ID的通知cancelId(int id){_notificationsPlugin.cancel(id);} }使用步骤 0.请求通知权限 android manifest.xml uses-permission android:namecom.android.alarm.permission.SET_ALARM/ uses-permission android:nameandroid.permission.SCHEDULE_EXACT_ALARM /ios Info.plist keyNSUserNotificationAlertIdentifier/key string我们需要您的许可来发送通知/string keyNSUserNotificationAlertTitle/key string请求通知权限/string keyNSUserNotificationAlertBody/key string我们希望能够在您允许的情况下发送通知。/string使用之前一定要代码里边获取通知权限 NotificationHelper.getInstance().requestNotificationPermissions();1.初始化 NotificationHelper.getInstance().initialize();2.使用 NotificationHelper.getInstance().zonedScheduleNotification(id: 10001, title: 科学研究, body: 研究开始了, scheduledDateTime: DateUtilss.getNowDateMs15or25DateTime(15));
http://www.w-s-a.com/news/705294/

相关文章:

  • 建设学校网站的原因网页设计实训报告1500
  • 网站建设客户来源江门网站设计华企立方
  • 自己如何做棋牌网站宁波网络推广优化方案
  • 深圳招聘网站推荐seo网站推广方案
  • 彩票网站开发 合法学术会议网站建设
  • 商务网站建设论文答辩pptseo技术博客
  • 怎样才能有自己的网站桂林搭建公司
  • 哪个网站做视频赚钱万科
  • 莆系医疗网站建设wp如何做网站地图
  • 网站建设应急处置方案团购网站 备案问题
  • 网站建设 岗位职责浙江中天建设集团有限公司网站
  • 西海岸建设局网站用wordpress建站学什么
  • 网站静态和动态学校网站建设流程步骤
  • 做群头像的网站在线怎么做俄语网站
  • 西安网站定制开发国内cms推荐
  • windows网站建设教程视频教程wordpress默认用户头像
  • 做网站需要什么软件wordpress会员邮件通知
  • 技术支持网站合肥网站搭建
  • 无为网站设计免费制作企业网站平台
  • 社交网站第一步怎么做房屋装修效果图用什么软件
  • 企业网站 批量备案合肥 网站建设
  • 如何提高网站索引量室内设计师之路网站
  • ps怎么做响应式网站布局图现在做网站都是怎么做的
  • 导购 网站模板网站主题选择
  • 毕业设计医院网站设计怎么做郑州铭功路网站建设
  • 网站根域名是什么php做商城网站步骤
  • 建设网站的那个公司好网站建设万首先金手指12
  • 广东民航机场建设有限公司网站网站开发后端用什么
  • 做风帆网站需要多少钱越野车网站模板
  • 如何做网站平台销售用狗做头像的网站