Commit e05501a6cc665da688fac936167dae4910d29a08

Authored by “gaiyaguang”
1 parent c2e14607

红点

@@ -404,9 +404,10 @@ @@ -404,9 +404,10 @@
404 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 404 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
405 CLANG_ENABLE_MODULES = YES; 405 CLANG_ENABLE_MODULES = YES;
406 CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; 406 CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
407 - CODE_SIGN_IDENTITY = "Apple Development"; 407 + CODE_SIGN_IDENTITY = "iPhone Developer";
  408 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
408 CODE_SIGN_STYLE = Automatic; 409 CODE_SIGN_STYLE = Automatic;
409 - CURRENT_PROJECT_VERSION = 136; 410 + CURRENT_PROJECT_VERSION = 141;
410 DEVELOPMENT_TEAM = 8J59HM8B82; 411 DEVELOPMENT_TEAM = 8J59HM8B82;
411 ENABLE_BITCODE = NO; 412 ENABLE_BITCODE = NO;
412 FRAMEWORK_SEARCH_PATHS = ( 413 FRAMEWORK_SEARCH_PATHS = (
@@ -419,7 +420,7 @@ @@ -419,7 +420,7 @@
419 "$(inherited)", 420 "$(inherited)",
420 "$(PROJECT_DIR)/Flutter", 421 "$(PROJECT_DIR)/Flutter",
421 ); 422 );
422 - MARKETING_VERSION = 1.3.6; 423 + MARKETING_VERSION = 1.4.1;
423 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 424 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
424 PRODUCT_NAME = "一键订"; 425 PRODUCT_NAME = "一键订";
425 PROVISIONING_PROFILE_SPECIFIER = ""; 426 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -546,9 +547,9 @@ @@ -546,9 +547,9 @@
546 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 547 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
547 CLANG_ENABLE_MODULES = YES; 548 CLANG_ENABLE_MODULES = YES;
548 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 549 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
549 - CODE_SIGN_IDENTITY = "Apple Development"; 550 + CODE_SIGN_IDENTITY = "iPhone Developer";
550 CODE_SIGN_STYLE = Automatic; 551 CODE_SIGN_STYLE = Automatic;
551 - CURRENT_PROJECT_VERSION = 136; 552 + CURRENT_PROJECT_VERSION = 141;
552 DEVELOPMENT_TEAM = 8J59HM8B82; 553 DEVELOPMENT_TEAM = 8J59HM8B82;
553 ENABLE_BITCODE = NO; 554 ENABLE_BITCODE = NO;
554 FRAMEWORK_SEARCH_PATHS = ( 555 FRAMEWORK_SEARCH_PATHS = (
@@ -561,7 +562,7 @@ @@ -561,7 +562,7 @@
561 "$(inherited)", 562 "$(inherited)",
562 "$(PROJECT_DIR)/Flutter", 563 "$(PROJECT_DIR)/Flutter",
563 ); 564 );
564 - MARKETING_VERSION = 1.3.6; 565 + MARKETING_VERSION = 1.4.1;
565 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 566 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
566 PRODUCT_NAME = "一键订"; 567 PRODUCT_NAME = "一键订";
567 PROVISIONING_PROFILE_SPECIFIER = ""; 568 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -579,9 +580,9 @@ @@ -579,9 +580,9 @@
579 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 580 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
580 CLANG_ENABLE_MODULES = YES; 581 CLANG_ENABLE_MODULES = YES;
581 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 582 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
582 - CODE_SIGN_IDENTITY = "Apple Development"; 583 + CODE_SIGN_IDENTITY = "iPhone Developer";
583 CODE_SIGN_STYLE = Automatic; 584 CODE_SIGN_STYLE = Automatic;
584 - CURRENT_PROJECT_VERSION = 136; 585 + CURRENT_PROJECT_VERSION = 141;
585 DEVELOPMENT_TEAM = 8J59HM8B82; 586 DEVELOPMENT_TEAM = 8J59HM8B82;
586 ENABLE_BITCODE = NO; 587 ENABLE_BITCODE = NO;
587 FRAMEWORK_SEARCH_PATHS = ( 588 FRAMEWORK_SEARCH_PATHS = (
@@ -594,7 +595,7 @@ @@ -594,7 +595,7 @@
594 "$(inherited)", 595 "$(inherited)",
595 "$(PROJECT_DIR)/Flutter", 596 "$(PROJECT_DIR)/Flutter",
596 ); 597 );
597 - MARKETING_VERSION = 1.3.6; 598 + MARKETING_VERSION = 1.4.1;
598 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 599 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
599 PRODUCT_NAME = "一键订"; 600 PRODUCT_NAME = "一键订";
600 PROVISIONING_PROFILE_SPECIFIER = ""; 601 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -33,6 +33,7 @@ import 'package:permission_handler/permission_handler.dart'; @@ -33,6 +33,7 @@ import 'package:permission_handler/permission_handler.dart';
33 import 'package:provider/provider.dart'; 33 import 'package:provider/provider.dart';
34 import 'package:shared_preferences/shared_preferences.dart'; 34 import 'package:shared_preferences/shared_preferences.dart';
35 import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; 35 import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
  36 +import 'package:flutter_app_badger/flutter_app_badger.dart';
36 37
37 class HomePage extends StatefulWidget { 38 class HomePage extends StatefulWidget {
38 final int initialIndex; //初始tab 39 final int initialIndex; //初始tab
@@ -51,6 +52,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -51,6 +52,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
51 int _currIndex = 1; 52 int _currIndex = 1;
52 Color _activeColor = MyColours.color_199095; 53 Color _activeColor = MyColours.color_199095;
53 Color _defaultColor = MyColours.color_999999; 54 Color _defaultColor = MyColours.color_999999;
  55 + int numPush = 0; //推送消息个数
54 56
55 Timer timer; 57 Timer timer;
56 58
@@ -103,6 +105,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -103,6 +105,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
103 105
104 //获取点击通知栏的自定义参数 106 //获取点击通知栏的自定义参数
105 _getIntent() async { 107 _getIntent() async {
  108 + _clearBadge();
106 Map param = await Tools().getIntent(); 109 Map param = await Tools().getIntent();
107 Map notifyParam = param; 110 Map notifyParam = param;
108 if (Platform.isIOS && param != null) { 111 if (Platform.isIOS && param != null) {
@@ -152,7 +155,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -152,7 +155,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
152 LogUtil.v("注册成功:$token"); 155 LogUtil.v("注册成功:$token");
153 // Utils.showToast("注册成功:$token"); 156 // Utils.showToast("注册成功:$token");
154 userTokenInit(token); 157 userTokenInit(token);
155 - XgFlutterPlugin().setAppBadge(0); 158 + // XgFlutterPlugin().setAppBadge(0);
156 } 159 }
157 }, 160 },
158 unRegistered: (String msg) async { 161 unRegistered: (String msg) async {
@@ -160,6 +163,8 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -160,6 +163,8 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
160 }, 163 },
161 onReceiveNotificationResponse: (Map<String, dynamic> msg) async { 164 onReceiveNotificationResponse: (Map<String, dynamic> msg) async {
162 LogUtil.v("flutter onReceiveNotificationResponse $msg"); 165 LogUtil.v("flutter onReceiveNotificationResponse $msg");
  166 + numPush++;
  167 + _addBadge();
163 }, 168 },
164 onReceiveMessage: (Map<String, dynamic> msg) async { 169 onReceiveMessage: (Map<String, dynamic> msg) async {
165 print("flutter onReceiveMessage $msg"); 170 print("flutter onReceiveMessage $msg");
@@ -167,8 +172,8 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -167,8 +172,8 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
167 xgPushDidSetBadge: (String msg) async { 172 xgPushDidSetBadge: (String msg) async {
168 print("flutter xgPushDidSetBadge: $msg"); 173 print("flutter xgPushDidSetBadge: $msg");
169 174
170 - /// 在此可设置应用角标  
171 - XgFlutterPlugin().setAppBadge(0); 175 + // /// 在此可设置应用角标
  176 + // XgFlutterPlugin().setAppBadge(0);
172 }, 177 },
173 xgPushDidBindWithIdentifier: (String msg) async { 178 xgPushDidBindWithIdentifier: (String msg) async {
174 print("flutter xgPushDidBindWithIdentifier: $msg"); 179 print("flutter xgPushDidBindWithIdentifier: $msg");
@@ -183,6 +188,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -183,6 +188,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
183 print("flutter xgPushDidClearAllIdentifiers: $msg"); 188 print("flutter xgPushDidClearAllIdentifiers: $msg");
184 }, 189 },
185 xgPushClickAction: (Map<String, dynamic> msg) async { 190 xgPushClickAction: (Map<String, dynamic> msg) async {
  191 + _clearBadge();
186 if (Platform.isIOS && msg != null && msg['custom'] != null) { 192 if (Platform.isIOS && msg != null && msg['custom'] != null) {
187 Map custom = json.decode(msg['custom'].toString()); 193 Map custom = json.decode(msg['custom'].toString());
188 switch (custom["messageType"].toString()) { 194 switch (custom["messageType"].toString()) {
@@ -233,6 +239,19 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -233,6 +239,19 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
233 xgCount++; 239 xgCount++;
234 } 240 }
235 241
  242 + void _addBadge() {
  243 + XgFlutterPlugin().setBadge(numPush);
  244 + XgFlutterPlugin().setAppBadge(numPush);
  245 + FlutterAppBadger.updateBadgeCount(numPush);
  246 + }
  247 +
  248 + void _clearBadge() async {
  249 + numPush = 0;
  250 + XgFlutterPlugin().setBadge(0);
  251 + XgFlutterPlugin().setAppBadge(0);
  252 + FlutterAppBadger.removeBadge();
  253 + }
  254 +
236 //初始化推送token 255 //初始化推送token
237 userTokenInit(String token) { 256 userTokenInit(String token) {
238 UserModel userModel = Provider.of<UserModel>(context, listen: false); 257 UserModel userModel = Provider.of<UserModel>(context, listen: false);
@@ -300,6 +300,13 @@ packages: @@ -300,6 +300,13 @@ packages:
300 description: flutter 300 description: flutter
301 source: sdk 301 source: sdk
302 version: "0.0.0" 302 version: "0.0.0"
  303 + flutter_app_badger:
  304 + dependency: "direct main"
  305 + description:
  306 + name: flutter_app_badger
  307 + url: "https://pub.flutter-io.cn"
  308 + source: hosted
  309 + version: "1.1.2"
303 flutter_blurhash: 310 flutter_blurhash:
304 dependency: transitive 311 dependency: transitive
305 description: 312 description:
@@ -87,6 +87,7 @@ dependencies: @@ -87,6 +87,7 @@ dependencies:
87 contacts_service: ^0.4.6 87 contacts_service: ^0.4.6
88 common_utils: ^1.1.3 88 common_utils: ^1.1.3
89 easy_contact_picker: ^0.0.2 89 easy_contact_picker: ^0.0.2
  90 + flutter_app_badger: ^1.1.2
90 91
91 92
92 dev_dependencies: 93 dev_dependencies: