Commit d452b017bcb7e5d177ed4414b6cf5f6774f154a5

Authored by 蓋亞光
2 parents 7df6abad 4ecf9509

合并冲突

@@ -11,14 +11,14 @@ if (flutterRoot == null) { @@ -11,14 +11,14 @@ if (flutterRoot == null) {
11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 } 12 }
13 13
14 -def flutterVersionCode = "145" 14 +def flutterVersionCode = "146"
15 if (flutterVersionCode == null) { 15 if (flutterVersionCode == null) {
16 - flutterVersionCode = '145' 16 + flutterVersionCode = '146'
17 } 17 }
18 18
19 -def flutterVersionName = "1.4.5" 19 +def flutterVersionName = "1.4.6"
20 if (flutterVersionName == null) { 20 if (flutterVersionName == null) {
21 - flutterVersionName = '1.4.5' 21 + flutterVersionName = '1.4.6'
22 } 22 }
23 23
24 apply plugin: 'com.android.application' 24 apply plugin: 'com.android.application'
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <uses-permission android:name="android.permission.READ_CONTACTS" /> 10 <uses-permission android:name="android.permission.READ_CONTACTS" />
11 <uses-permission android:name="android.permission.WRITE_CONTACTS" /> 11 <uses-permission android:name="android.permission.WRITE_CONTACTS" />
12 <uses-permission android:name="android.permission.READ_CONTACTS"/> 12 <uses-permission android:name="android.permission.READ_CONTACTS"/>
13 - 13 + <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
14 <application 14 <application
15 android:name="io.flutter.app.FlutterApplication" 15 android:name="io.flutter.app.FlutterApplication"
16 android:label="一键订" 16 android:label="一键订"
1 -c71e777004aab201609920eac28801f9  
  1 +<<<<<<< HEAD
  2 +c71e777004aab201609920eac28801f9
  3 +=======
  4 +7babc7873f8d177769b987ba4c6c2911
  5 +>>>>>>> 4ecf950986f1856303c83ccacadc2b15efeb20ac
@@ -12,6 +12,8 @@ PODS: @@ -12,6 +12,8 @@ PODS:
12 - easy_contact_picker (0.0.1): 12 - easy_contact_picker (0.0.1):
13 - Flutter 13 - Flutter
14 - Flutter (1.0.0) 14 - Flutter (1.0.0)
  15 + - flutter_app_badger (0.0.1):
  16 + - Flutter
15 - flutter_bugly (0.0.1): 17 - flutter_bugly (0.0.1):
16 - Bugly 18 - Bugly
17 - Flutter 19 - Flutter
@@ -56,6 +58,7 @@ DEPENDENCIES: @@ -56,6 +58,7 @@ DEPENDENCIES:
56 - device_info (from `.symlinks/plugins/device_info/ios`) 58 - device_info (from `.symlinks/plugins/device_info/ios`)
57 - easy_contact_picker (from `.symlinks/plugins/easy_contact_picker/ios`) 59 - easy_contact_picker (from `.symlinks/plugins/easy_contact_picker/ios`)
58 - Flutter (from `Flutter`) 60 - Flutter (from `Flutter`)
  61 + - flutter_app_badger (from `.symlinks/plugins/flutter_app_badger/ios`)
59 - flutter_bugly (from `.symlinks/plugins/flutter_bugly/ios`) 62 - flutter_bugly (from `.symlinks/plugins/flutter_bugly/ios`)
60 - flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`) 63 - flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`)
61 - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) 64 - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
@@ -91,6 +94,8 @@ EXTERNAL SOURCES: @@ -91,6 +94,8 @@ EXTERNAL SOURCES:
91 :path: ".symlinks/plugins/easy_contact_picker/ios" 94 :path: ".symlinks/plugins/easy_contact_picker/ios"
92 Flutter: 95 Flutter:
93 :path: Flutter 96 :path: Flutter
  97 + flutter_app_badger:
  98 + :path: ".symlinks/plugins/flutter_app_badger/ios"
94 flutter_bugly: 99 flutter_bugly:
95 :path: ".symlinks/plugins/flutter_bugly/ios" 100 :path: ".symlinks/plugins/flutter_bugly/ios"
96 flutter_statusbarcolor: 101 flutter_statusbarcolor:
@@ -126,6 +131,7 @@ SPEC CHECKSUMS: @@ -126,6 +131,7 @@ SPEC CHECKSUMS:
126 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 131 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
127 easy_contact_picker: 9ab9dc70e8ddde6e76a19ffc482d7bf899868730 132 easy_contact_picker: 9ab9dc70e8ddde6e76a19ffc482d7bf899868730
128 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec 133 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
  134 + flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68
129 flutter_bugly: c9800f4d5bc5bdc27ffdde3417a26ba44266e0c3 135 flutter_bugly: c9800f4d5bc5bdc27ffdde3417a26ba44266e0c3
130 flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259 136 flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259
131 fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b 137 fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b
@@ -254,6 +254,7 @@ @@ -254,6 +254,7 @@
254 "${BUILT_PRODUCTS_DIR}/contacts_service/contacts_service.framework", 254 "${BUILT_PRODUCTS_DIR}/contacts_service/contacts_service.framework",
255 "${BUILT_PRODUCTS_DIR}/device_info/device_info.framework", 255 "${BUILT_PRODUCTS_DIR}/device_info/device_info.framework",
256 "${BUILT_PRODUCTS_DIR}/easy_contact_picker/easy_contact_picker.framework", 256 "${BUILT_PRODUCTS_DIR}/easy_contact_picker/easy_contact_picker.framework",
  257 + "${BUILT_PRODUCTS_DIR}/flutter_app_badger/flutter_app_badger.framework",
257 "${BUILT_PRODUCTS_DIR}/flutter_statusbarcolor/flutter_statusbarcolor.framework", 258 "${BUILT_PRODUCTS_DIR}/flutter_statusbarcolor/flutter_statusbarcolor.framework",
258 "${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework", 259 "${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework",
259 "${BUILT_PRODUCTS_DIR}/install_plugin/install_plugin.framework", 260 "${BUILT_PRODUCTS_DIR}/install_plugin/install_plugin.framework",
@@ -274,6 +275,7 @@ @@ -274,6 +275,7 @@
274 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/contacts_service.framework", 275 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/contacts_service.framework",
275 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework", 276 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework",
276 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/easy_contact_picker.framework", 277 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/easy_contact_picker.framework",
  278 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_app_badger.framework",
277 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_statusbarcolor.framework", 279 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_statusbarcolor.framework",
278 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework", 280 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework",
279 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/install_plugin.framework", 281 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/install_plugin.framework",
@@ -404,9 +406,14 @@ @@ -404,9 +406,14 @@
404 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 406 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
405 CLANG_ENABLE_MODULES = YES; 407 CLANG_ENABLE_MODULES = YES;
406 CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; 408 CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
407 - CODE_SIGN_IDENTITY = "Apple Development"; 409 + CODE_SIGN_IDENTITY = "iPhone Developer";
  410 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
408 CODE_SIGN_STYLE = Automatic; 411 CODE_SIGN_STYLE = Automatic;
  412 +<<<<<<< HEAD
409 CURRENT_PROJECT_VERSION = 145; 413 CURRENT_PROJECT_VERSION = 145;
  414 +=======
  415 + CURRENT_PROJECT_VERSION = 146;
  416 +>>>>>>> 4ecf950986f1856303c83ccacadc2b15efeb20ac
410 DEVELOPMENT_TEAM = 8J59HM8B82; 417 DEVELOPMENT_TEAM = 8J59HM8B82;
411 ENABLE_BITCODE = NO; 418 ENABLE_BITCODE = NO;
412 FRAMEWORK_SEARCH_PATHS = ( 419 FRAMEWORK_SEARCH_PATHS = (
@@ -419,7 +426,11 @@ @@ -419,7 +426,11 @@
419 "$(inherited)", 426 "$(inherited)",
420 "$(PROJECT_DIR)/Flutter", 427 "$(PROJECT_DIR)/Flutter",
421 ); 428 );
  429 +<<<<<<< HEAD
422 MARKETING_VERSION = 1.4.5; 430 MARKETING_VERSION = 1.4.5;
  431 +=======
  432 + MARKETING_VERSION = 1.4.6;
  433 +>>>>>>> 4ecf950986f1856303c83ccacadc2b15efeb20ac
423 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 434 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
424 PRODUCT_NAME = "一键订"; 435 PRODUCT_NAME = "一键订";
425 PROVISIONING_PROFILE_SPECIFIER = ""; 436 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -546,9 +557,13 @@ @@ -546,9 +557,13 @@
546 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 557 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
547 CLANG_ENABLE_MODULES = YES; 558 CLANG_ENABLE_MODULES = YES;
548 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 559 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
549 - CODE_SIGN_IDENTITY = "Apple Development"; 560 + CODE_SIGN_IDENTITY = "iPhone Developer";
550 CODE_SIGN_STYLE = Automatic; 561 CODE_SIGN_STYLE = Automatic;
  562 +<<<<<<< HEAD
551 CURRENT_PROJECT_VERSION = 145; 563 CURRENT_PROJECT_VERSION = 145;
  564 +=======
  565 + CURRENT_PROJECT_VERSION = 146;
  566 +>>>>>>> 4ecf950986f1856303c83ccacadc2b15efeb20ac
552 DEVELOPMENT_TEAM = 8J59HM8B82; 567 DEVELOPMENT_TEAM = 8J59HM8B82;
553 ENABLE_BITCODE = NO; 568 ENABLE_BITCODE = NO;
554 FRAMEWORK_SEARCH_PATHS = ( 569 FRAMEWORK_SEARCH_PATHS = (
@@ -561,7 +576,11 @@ @@ -561,7 +576,11 @@
561 "$(inherited)", 576 "$(inherited)",
562 "$(PROJECT_DIR)/Flutter", 577 "$(PROJECT_DIR)/Flutter",
563 ); 578 );
  579 +<<<<<<< HEAD
564 MARKETING_VERSION = 1.4.5; 580 MARKETING_VERSION = 1.4.5;
  581 +=======
  582 + MARKETING_VERSION = 1.4.6;
  583 +>>>>>>> 4ecf950986f1856303c83ccacadc2b15efeb20ac
565 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 584 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
566 PRODUCT_NAME = "一键订"; 585 PRODUCT_NAME = "一键订";
567 PROVISIONING_PROFILE_SPECIFIER = ""; 586 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -579,9 +598,13 @@ @@ -579,9 +598,13 @@
579 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 598 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
580 CLANG_ENABLE_MODULES = YES; 599 CLANG_ENABLE_MODULES = YES;
581 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 600 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
582 - CODE_SIGN_IDENTITY = "Apple Development"; 601 + CODE_SIGN_IDENTITY = "iPhone Developer";
583 CODE_SIGN_STYLE = Automatic; 602 CODE_SIGN_STYLE = Automatic;
  603 +<<<<<<< HEAD
584 CURRENT_PROJECT_VERSION = 145; 604 CURRENT_PROJECT_VERSION = 145;
  605 +=======
  606 + CURRENT_PROJECT_VERSION = 146;
  607 +>>>>>>> 4ecf950986f1856303c83ccacadc2b15efeb20ac
585 DEVELOPMENT_TEAM = 8J59HM8B82; 608 DEVELOPMENT_TEAM = 8J59HM8B82;
586 ENABLE_BITCODE = NO; 609 ENABLE_BITCODE = NO;
587 FRAMEWORK_SEARCH_PATHS = ( 610 FRAMEWORK_SEARCH_PATHS = (
@@ -594,7 +617,11 @@ @@ -594,7 +617,11 @@
594 "$(inherited)", 617 "$(inherited)",
595 "$(PROJECT_DIR)/Flutter", 618 "$(PROJECT_DIR)/Flutter",
596 ); 619 );
  620 +<<<<<<< HEAD
597 MARKETING_VERSION = 1.4.5; 621 MARKETING_VERSION = 1.4.5;
  622 +=======
  623 + MARKETING_VERSION = 1.4.6;
  624 +>>>>>>> 4ecf950986f1856303c83ccacadc2b15efeb20ac
598 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 625 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
599 PRODUCT_NAME = "一键订"; 626 PRODUCT_NAME = "一键订";
600 PROVISIONING_PROFILE_SPECIFIER = ""; 627 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,14 +155,16 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -152,14 +155,16 @@ 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 {
159 print("flutter unRegistered: $msg"); 162 print("flutter unRegistered: $msg");
160 }, 163 },
161 onReceiveNotificationResponse: (Map<String, dynamic> msg) async { 164 onReceiveNotificationResponse: (Map<String, dynamic> msg) async {
162 - LogUtil.v("flutter onReceiveNotificationResponse $msg"); 165 + print("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,20 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -233,6 +239,20 @@ 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(VoidCallback callback) async {
  249 + numPush = 0;
  250 + XgFlutterPlugin().setBadge(0);
  251 + XgFlutterPlugin().setAppBadge(0);
  252 + FlutterAppBadger.removeBadge();
  253 + callback();
  254 + }
  255 +
236 //初始化推送token 256 //初始化推送token
237 userTokenInit(String token) { 257 userTokenInit(String token) {
238 UserModel userModel = Provider.of<UserModel>(context, listen: false); 258 UserModel userModel = Provider.of<UserModel>(context, listen: false);
@@ -266,7 +286,10 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -266,7 +286,10 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
266 super.didChangeAppLifecycleState(state); 286 super.didChangeAppLifecycleState(state);
267 switch (state) { 287 switch (state) {
268 case AppLifecycleState.resumed: //应用前台可见 288 case AppLifecycleState.resumed: //应用前台可见
269 - getUntreatedMessage(); 289 + _clearBadge(() {
  290 + getUntreatedMessage();
  291 + });
  292 +
270 break; 293 break;
271 case AppLifecycleState.inactive: 294 case AppLifecycleState.inactive:
272 print('inactive'); 295 print('inactive');
@@ -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: