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

重庆南岸营销型网站建设公司推荐海盐网站建设

重庆南岸营销型网站建设公司推荐,海盐网站建设,响应式网页设计原理,专业电商网站建设1、申请极光账号和建立应用 极光推送的官方网址为#xff1a;https://www.jiguang.cn/ 注册好后#xff0c;进入服务中心,然后再进入开发者平台#xff0c;点击创建应用。 这时候会出现新页面#xff0c;让你填写“应用名称”和上传“应用图标”。 创建完成#xff0c;极…1、申请极光账号和建立应用 极光推送的官方网址为https://www.jiguang.cn/ 注册好后进入服务中心,然后再进入开发者平台点击创建应用。 这时候会出现新页面让你填写“应用名称”和上传“应用图标”。 创建完成极光平台就会给我们两个key。 appKey : 移动客户端使用的keyMaster Secret 服务端使用的key 我们这里只做移动端不做服务端所以只需要appKey。得到这个Key也算是极光平台操作完了 2、加入dependencies依赖 github网址:https://github.com/jpush/jpush-flutter-plugin 要使用极光推送插件必须先下载包要下载包就需要先添加依赖直接把下面的代码加入pubspec.yaml文件中。 jpush_flutter: 0.0.11写完代码后选择Android Studio右上角的Packages get进行下载下载完成后进行操作。 3、build.gradle添加可以和cpu型号代码 打开android/app/src/build.gradle文件加入如下代码 defaultConfig {applicationId sscai.club.flutter_shopminSdkVersion 16targetSdkVersion 28versionCode flutterVersionCode.toInteger()versionName flutterVersionNametestInstrumentationRunner android.support.test.runner.AndroidJUnitRunner/*新加入的*/ndk {/*选择要添加的对应 cpu 类型的 .so 库。abiFilters armeabi, armeabi-v7a, x86, x86_64, mips, mips64// arm64-v8a,/*还可以添加}manifestPlaceholders  [JPUSH_PKGNAME: applicationId,JPUSH_APPKEY : 这里写入你自己申请的Key哦, /*NOTE: JPush 上注册的包名对应的 Appkey.*/JPUSH_CHANNEL: developer-default, /*暂时填写默认值即可.*/]/*新加入的*/ }详细请参考https://github.com/jpush/jpush-flutter-plugin 4、主要代码编写 在 main.dart 中引入依赖 import package:flutter/material.dart; import dart:async;import package:flutter/services.dart; import package:jpush_flutter/jpush_flutter.dart;编写initPlatformState方法 Futurevoid initPlatformState() async {String platformVersion;try {/*监听响应方法的编写*/jpush.addEventHandler(onReceiveNotification: (MapString, dynamic message) async {print(flutter 接收到推送: $message);setState(() {debugLable  接收到推送: $message;});});} on PlatformException {platformVersion  平台版本获取失败请检查;}if (!mounted){return;}setState(() {debugLable  platformVersion;}); }编写build的视图 overrideWidget build(BuildContext context) {return new MaterialApp(home: new Scaffold(appBar: new AppBar(title: const Text(极光推送),),body: new Center(child: new Column(children:[new Text(结果: $debugLable\n),new RaisedButton(child: new Text(点击发送推送消息\n,),onPressed: () {/*三秒后出发本地推送*/var fireDate  DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch  3000);var localNotification  LocalNotification(id: 234,title: 我是推送测试标题,buildId: 1,content: 看到了说明已经成功了,fireTime: fireDate,subtitle: 一个测试,);jpush.sendLocalNotification(localNotification).then((res) {setState(() {debugLable  res;});});}),])),),);}main.dart 完整代码 import package:flutter/material.dart; import dart:async;import package:flutter/services.dart; import package:jpush_flutter/jpush_flutter.dart;void main()  runApp(new MyApp());class MyApp extends StatefulWidget {override_MyAppState createState()  new _MyAppState(); }class _MyAppState extends StateMyApp {String debugLable  Unknown;   /*错误信息*/final JPush jpush  new JPush(); /* 初始化极光插件*/overridevoid initState() {super.initState();initPlatformState();  /*极光插件平台初始化*/}Futurevoid initPlatformState() async {String platformVersion;try {/*监听响应方法的编写*/jpush.addEventHandler(onReceiveNotification: (MapString, dynamic message) async {print(flutter 接收到推送: $message);setState(() {debugLable  接收到推送: $message;});});} on PlatformException {platformVersion  平台版本获取失败请检查;}if (!mounted){return;}setState(() {debugLable  platformVersion;});}/*编写视图*/overrideWidget build(BuildContext context) {return new MaterialApp(home: new Scaffold(appBar: new AppBar(title: const Text(极光推送),),body: new Center(child: new Column(children:[new Text(结果: $debugLable\n),new RaisedButton(child: new Text(点击发送推送消息\n,),onPressed: () {/*三秒后出发本地推送*/var fireDate  DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch  3000);var localNotification  LocalNotification(id: 234,title: 我是推送测试标题,buildId: 1,content: 看到了说明已经成功了,fireTime: fireDate,subtitle: 一个测试,);jpush.sendLocalNotification(localNotification).then((res) {setState(() {debugLable  res;});});}),])),),);} }效果图 4、扩展几个方法 收到推送提醒 监听addReceiveNotificationListener方法 /* * 收到推送提醒 * */void _ReceiveNotification() async {FlutterJPush.addReceiveNotificationListener((JPushNotification notification) {setState(() {/// 收到推送print(收到推送提醒: $notification);});});}打开推送提醒 监听 addReceiveNotificationListener方法 /** 打开推送提醒* */void _OpenNotification() async {FlutterJPush.addReceiveOpenNotificationListener((JPushNotification notification) {setState(() {print(打开了推送提醒: $notification);});});}监听接收自定义消息 一般项目这个方法会用的比较多吧 监听 addReceiveCustomMsgListener方法 /** 监听接收自定义消息* */void _ReceiveCustomMsg() async {FlutterJPush.addReceiveCustomMsgListener((JPushMessage msg) {setState(() {print(收到推送消息提醒: $msg);});});}
http://www.pierceye.com/news/246900/

相关文章:

  • 如何建手机网站网站能否做二维码
  • 南京网站建设 雷仁网上海网站制作网络推广方法
  • 营销型网站怎么做安阳县有多少个乡镇
  • 网站评论 设计天气网站建设
  • 潍坊市住房和城乡建设局网站哈尔滨最新发布公告
  • 白云网站 建设信科网络制作网站软件网站
  • 房产网站的建设想发布oa网站 需要备案吗
  • 帮别人做钓鱼网站吗海口网站建设过程
  • 广州php网站建设做网站的公司推荐
  • 百度一下建设银行网站首页网上购物都有哪些网站
  • 装饰公司营销型网站建设idc服务器租赁
  • 广告投放跟网站建设一样吗视频网站能备案吗
  • 哪些网站可以找到兼职做报表的学校网站建设价格明细表
  • 域名购买哪个网站好wordpress 转载插件
  • 网站百度提示风险网站开发 安全
  • 厦门网站建设建网站如何做一个网页项目
  • 锦州市网站建设腾讯企点怎么群发
  • 移动端网站开发哪家好总结格式模板
  • 东山县建设银行网站民宿网站开发的开题报告
  • 北京企业网站seo平台社交网站模板下载
  • 旅游做攻略用什么网站wordpress破解版
  • 杭州做购物网站第一次跑业务怎么找客户
  • 做软件好还是做网站好建筑公司年度工作总结报告
  • 陕西建设 节水 官方网站论坛怎样发帖推广
  • 二合一收款码免费制作网站营销型网站代理
  • 网站建设的技术方案模板淘宝客做网站链接
  • 梅州市网站制作页面简洁的导航网站
  • 绵阳房产网站建设自学广告设计该怎么入手
  • 火星wap建站宏大建设集团有限公司网站
  • 免费搭建业网站西地那非片有延时效果吗