Commit 4ae801a2549c06bd4230baec4069bbd141f05956

Authored by gaiyaguang
1 parent 6d4505c5

上传联系人,推送本地集成

{
"client":{
"cp_id":"260086000252264275",
"product_id":"9105385871708598142",
"client_id":"326681575729136832",
"client_secret":"A8D20078A192C1BD87C6B3EB5B597EF654901AE981E64701D66131A4E56A3AE9",
"app_id":"101934783",
"package_name":"com.naji.one_key",
"api_key":"CV6kBSEh4lAr9VF9v+geTdQebNtGEGQ4HcgN1igodItOCuGghaF1do+cxeVplpcEpe3pf3nwbkChLzCvkxtHvQOaPkTs"
},
"configuration_version":"1.0"
}
\ No newline at end of file
... ... @@ -13,12 +13,12 @@ if (flutterRoot == null) {
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
flutterVersionCode = '7'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
flutterVersionName = '1.0.7'
}
apply plugin: 'com.android.application'
... ... @@ -53,28 +53,13 @@ android {
}
manifestPlaceholders = [
JPUSH_PKGNAME : applicationId,
JPUSH_APPKEY : "27ceb79c44af41ad99202f7a", // NOTE: JPush 上注册的包名对应的 Appkey.
JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
HUAWEI_APPID:"101934783",//华为平台注册的appid
XIAOMI_APPKEY : "MI-5811835841457", // 小米平台注册的appkey
XIAOMI_APPID : "MI-2882303761518358457", // 小米平台注册的appid
OPPO_APPKEY : "OP-94d77d10e7bb4c60bcf18a84c8ca8bdd", // OPPO平台注册的appkey
OPPO_APPID : "OP-30260281", // OPPO平台注册的appid
OPPO_APPSECRET: "OP-9b7e372f93794593953f93f118619570",//OPPO平台注册的appsecret
// VIVO_APPKEY : "5811835841457", // VIVO平台注册的appkey
// VIVO_APPID : "2882303761518358457", // VIVO平台注册的appid
XG_ACCESS_ID : '1500012875',
XG_ACCESS_KEY : 'AVR2GJERH0HC',
HW_APPID : '102832405',
VIVO_APPID: "103886384",
VIVO_APPKEY:"5a04e5c3485c0b19a2911c95dcaff5d2",
PACKAGE_NAME : "com.naji.one_key",// 小米通道
]
// manifestPlaceholders = [
// XG_ACCESS_ID : '2100332241',
// XG_ACCESS_KEY : 'A51T8RX1HS1W',
// XG_ACCESS_SCHEME: 'fake_push',// 非官方参数,可自定义,统一打开方式为 intent
// HW_APPID : '100728875',
// XIAOMI_APPID : '2882303761517989384',
// XIAOMI_APPKEY : '5141798993384',
// PACKAGE_NAME : "${applicationId}",// 小米通道
// ]
}
signingConfigs {
... ... @@ -115,17 +100,8 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//华为推送
implementation 'cn.jiguang.sdk.plugin:huawei:3.5.8'
implementation 'com.huawei.hms:push:3.0.3.301'
//小米推送
implementation 'cn.jiguang.sdk.plugin:xiaomi:3.5.8'
//OPPO推送
implementation 'cn.jiguang.sdk.plugin:oppo:3.5.8'
//
// //vivo推送
// implementation 'cn.jiguang.sdk.plugin:vivo:3.5.8'
implementation 'com.tencent.tpns:huawei:1.2.0.3-release'// 华为推送
implementation 'com.tencent.tpns:xiaomi:1.2.0.3-release' // 小米推送
implementation 'com.tencent.tpns:oppo:1.2.0.3-release' // OPPO 推送
implementation 'com.tencent.tpns:vivo:1.2.0.3-release' // vivo 推送
}
... ...
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.naji.one_key">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
... ... @@ -32,13 +32,6 @@
</intent-filter>
</activity>
<service
android:name="cn.jpush.android.service.PluginHuaweiPlatformsService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
... ...
No preview for this file type
No preview for this file type
{
"tpns": {
"access_id": "1500012875",
"access_key": "AVR2GJERH0HC"
},
"com.naji.one_key": {
"channel": {
"enable": true
}
},
"debug": false,
"version": "1.2.0.3"
}
\ No newline at end of file
... ...
# Uncomment this line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
... ...
PODS:
- audioplayers (0.0.1):
- Flutter
- Bugly (2.5.71)
- connectivity (0.0.1):
- Flutter
- Reachability
- connectivity_for_web (0.1.0):
- Flutter
- connectivity_macos (0.0.1):
- Flutter
- contacts_service (0.2.2):
... ... @@ -11,33 +14,36 @@ PODS:
- device_info (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_bugly (0.0.1):
- Bugly
- Flutter
- flutter_statusbarcolor (0.0.1):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- fluwx (0.0.1):
- Flutter
- WechatOpenSDK (= 1.8.6.2)
- WechatOpenSDK (= 1.8.7.1)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- install_plugin (0.0.1):
- Flutter
- JCore (2.2.5)
- JPush (3.3.2):
- JCore (< 3.0.0, >= 2.0.0)
- jpush_flutter (0.0.2):
- package_info (0.0.1):
- Flutter
- JPush
- path_provider (0.0.1):
- Flutter
- path_provider_linux (0.0.1):
- Flutter
- path_provider_macos (0.0.1):
- Flutter
- permission_handler (4.4.0):
- "permission_handler (4.4.0+hotfix.4)":
- Flutter
- Reachability (3.2)
- shared_preferences (0.0.1):
- Flutter
- shared_preferences_linux (0.0.1):
- Flutter
- shared_preferences_macos (0.0.1):
- Flutter
- shared_preferences_web (0.0.1):
... ... @@ -45,50 +51,58 @@ PODS:
- sqflite (0.0.1):
- Flutter
- FMDB (~> 2.7.2)
- TPNS-iOS (1.2.7.2)
- tpns_flutter_plugin (1.0.4):
- Flutter
- TPNS-iOS (= 1.2.7.2)
- url_launcher (0.0.1):
- Flutter
- url_launcher_linux (0.0.1):
- Flutter
- url_launcher_macos (0.0.1):
- Flutter
- url_launcher_web (0.0.1):
- Flutter
<<<<<<< HEAD
- WechatOpenSDK (1.8.6.2)
=======
- webview_flutter (0.0.1):
- Flutter
- WechatOpenSDK (1.8.7.1)
>>>>>>> dev
DEPENDENCIES:
- audioplayers (from `.symlinks/plugins/audioplayers/ios`)
- connectivity (from `.symlinks/plugins/connectivity/ios`)
- connectivity_for_web (from `.symlinks/plugins/connectivity_for_web/ios`)
- connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`)
- contacts_service (from `.symlinks/plugins/contacts_service/ios`)
- device_info (from `.symlinks/plugins/device_info/ios`)
- Flutter (from `Flutter`)
- flutter_bugly (from `.symlinks/plugins/flutter_bugly/ios`)
- flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- fluwx (from `.symlinks/plugins/fluwx/ios`)
- install_plugin (from `.symlinks/plugins/install_plugin/ios`)
- jpush_flutter (from `.symlinks/plugins/jpush_flutter/ios`)
- package_info (from `.symlinks/plugins/package_info/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- tpns_flutter_plugin (from `.symlinks/plugins/tpns_flutter_plugin/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
- url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`)
- url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)
- webview_flutter (from `.symlinks/plugins/webview_flutter/ios`)
SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
trunk:
- Bugly
- FMDB
- JCore
- JPush
- Reachability
- TPNS-iOS
- WechatOpenSDK
EXTERNAL SOURCES:
... ... @@ -96,6 +110,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/audioplayers/ios"
connectivity:
:path: ".symlinks/plugins/connectivity/ios"
connectivity_for_web:
:path: ".symlinks/plugins/connectivity_for_web/ios"
connectivity_macos:
:path: ".symlinks/plugins/connectivity_macos/ios"
contacts_service:
... ... @@ -104,6 +120,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/device_info/ios"
Flutter:
:path: Flutter
flutter_bugly:
:path: ".symlinks/plugins/flutter_bugly/ios"
flutter_statusbarcolor:
:path: ".symlinks/plugins/flutter_statusbarcolor/ios"
fluttertoast:
... ... @@ -112,24 +130,32 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/fluwx/ios"
install_plugin:
:path: ".symlinks/plugins/install_plugin/ios"
jpush_flutter:
:path: ".symlinks/plugins/jpush_flutter/ios"
package_info:
:path: ".symlinks/plugins/package_info/ios"
path_provider:
:path: ".symlinks/plugins/path_provider/ios"
path_provider_linux:
:path: ".symlinks/plugins/path_provider_linux/ios"
path_provider_macos:
:path: ".symlinks/plugins/path_provider_macos/ios"
permission_handler:
:path: ".symlinks/plugins/permission_handler/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_linux:
:path: ".symlinks/plugins/shared_preferences_linux/ios"
shared_preferences_macos:
:path: ".symlinks/plugins/shared_preferences_macos/ios"
shared_preferences_web:
:path: ".symlinks/plugins/shared_preferences_web/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
tpns_flutter_plugin:
:path: ".symlinks/plugins/tpns_flutter_plugin/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"
url_launcher_linux:
:path: ".symlinks/plugins/url_launcher_linux/ios"
url_launcher_macos:
:path: ".symlinks/plugins/url_launcher_macos/ios"
url_launcher_web:
... ... @@ -139,37 +165,39 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
audioplayers: 84f968cea3f2deab00ec4f8ff53358b3c0b3992c
connectivity: 6e94255659cc86dcbef1d452ad3e0491bb1b3e75
Bugly: fd066c75c4a0eca1440f9b6a84bd37d51bfc85ac
connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467
connectivity_for_web: 2b8584556930d4bd490d82b836bcf45067ce345b
connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191
contacts_service: 849e1f84281804c8bfbec1b4c3eedcb23c5d3eca
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_bugly: c9800f4d5bc5bdc27ffdde3417a26ba44266e0c3
flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259
fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b
fluwx: 03e098a7284c556d7b197e0b82984eb0b25183af
fluwx: 07a55ed66bf3a4961e836a2a411b02dcada32902
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
install_plugin: a13e7ddd2bab0c701b48cd359c26d0394125b6fb
JCore: d75c0306dc99875d323d23e5a063b3a3ef22335a
JPush: 9468c84a3809dc3ac2fc1c89c6d1d6c858a91bf5
jpush_flutter: 69133df35eaf9135e540549b154d992c44f8ee44
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
permission_handler: f615215121f43c1640d2b8500d4ad749512828a8
permission_handler: 8278954f2382902f63f00dd8828769c0bd6d511b
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0
url_launcher: a1c0cc845906122c4784c542523d8cacbded5626
TPNS-iOS: 9b35473a4a0d07f2c2730ea1e66c6749c2b98095
tpns_flutter_plugin: 8dbbee157aab91a878f64d056c1383726a6c5c4d
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
<<<<<<< HEAD
WechatOpenSDK: 8b3ba4239193d1112205c139c94e21934e8f369a
=======
webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96
WechatOpenSDK: 6a4d1436c15b3b5fe2a0bd383f3046010186da44
>>>>>>> dev
PODFILE CHECKSUM: a5c9f5cbedb217afa5108d75ed888500ab689803
PODFILE CHECKSUM: 6d186dc4668603071619657511aa873d9a684d13
COCOAPODS: 1.9.1
... ...
... ... @@ -84,5 +84,9 @@
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>XG_ACCESS_ID</key>
<string>${1600012876}</string>
<key>XG_ACCESS_KEY</key>
<string>${INUIMFK21WGH}</string>
</dict>
</plist>
... ...
... ... @@ -11,6 +11,7 @@ import 'package:one_key/provider/message_dialog_model.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
import 'app.dart';
import 'net/dio_util.dart';
... ... @@ -79,6 +80,7 @@ class MyAppState extends State<MyApp>{
LogUtil.v("is installed $result");
}
//初始化dio
initDio() {
DioUtil.openDebug();
Options options = DioUtil.getDefOptions();
... ...
import 'dart:async';
import 'dart:convert';
//import 'package:fake_push/fake_push.dart' as fake;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:one_key/models/message.dart';
import 'package:one_key/pages/message/message_page.dart';
import 'package:one_key/pages/my/my_page.dart';
import 'package:one_key/pages/notebook/notebook_page.dart';
... ... @@ -19,11 +14,10 @@ import 'package:one_key/provider/update_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/log_util.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
class HomePage extends StatefulWidget{
... ... @@ -40,22 +34,14 @@ class HomePage extends StatefulWidget{
class HomePageState extends State<HomePage>{
// 信鸽推送
// fake.Push _push = fake.Push();
// StreamSubscription<String> _receiveDeviceToken;
// StreamSubscription<fake.Message> _receiveMessage;
// StreamSubscription<fake.Message> _receiveNotification;
// StreamSubscription<String> _launchNotification;
// StreamSubscription<String> _resumeNotification;
// 极光推送
final JPush jpush = new JPush();
List<Widget> pages = List<Widget>();
int _currIndex = 1;
Color _activeColor = MyColours.color_2bb5b7;
Color _defaultColor = MyColours.color_bfbfbf;
Timer timer;
@override
void initState() {
// TODO: implement initState
... ... @@ -75,155 +61,91 @@ class HomePageState extends State<HomePage>{
create: (_)=>MyModel(),
child: MyPage(),
));
initJPush();
// initXinge();
WidgetsBinding.instance.addPostFrameCallback((_){
if(widget.initialIndex==0)return;
ContactModel.getInstance().uploadLocalContact(context);
// getUntreatedMessage();
// UpdateModel updateModel=new UpdateModel();
// updateModel.checkUpdate(context);
});
}
Future<void> initJPush() async {
try {
jpush.addEventHandler(
onReceiveNotification: (Map<String, dynamic> message) async {
LogUtil.v("flutter onReceiveNotification: $message");
Map<String,dynamic> messageMap=(json.decode(message["extras"]["cn.jpush.android.EXTRA"]) as Map<String,dynamic>)["extras"];
Provider.of<MessageDialogModel>(context,listen: false).addMessage(context,Message.fromJson(messageMap));
}, onOpenNotification: (Map<String, dynamic> message) async {
LogUtil.v("flutter onOpenNotification: $message");
NavigatorUtil.goHomePage(context,initialIndex: 0);
}, onReceiveMessage: (Map<String, dynamic> message) async {
LogUtil.v("flutter onReceiveMessage: $message");
}, onReceiveNotificationAuthorization:
(Map<String, dynamic> message) async {
LogUtil.v("flutter onReceiveNotificationAuthorization: $message");
ContactModel.getInstance().uploadLocalContact(context);
timer=Timer.periodic(Duration(minutes: 3), (_){
getUntreatedMessage();
});
} on PlatformException {}
jpush.setup(
appKey: "27ceb79c44af41ad99202f7a", //你自己应用的 AppKey
channel: "theChannel",
production: false,
debug: true,
);
jpush.applyPushAuthority(
new NotificationSettingsIOS(sound: true, alert: true, badge: false));
// Platform messages may fail, so we use a try/catch PlatformException.
jpush.getRegistrationID().then((rid) {
LogUtil.v("flutter get registration id : $rid");
userTokenInit(rid);
});
jpush.isNotificationEnabled().then((bool value) {
if (!value) {
//没有打开通知
jpush.openSettingsForNotification();
}
UpdateModel updateModel=new UpdateModel();
updateModel.checkUpdate(context);
});
initPlatformState();
}
//初始化信鸽推送
void initXinge(){
// _receiveDeviceToken =
// _push.receiveDeviceToken().listen(_handleReceiveDeviceToken);
// _receiveMessage = _push.receiveMessage().listen(_handleReceiveMessage);
// _receiveNotification =
// _push.receiveNotification().listen(_handleReceiveNotification);
// _launchNotification =
// _push.launchNotification().listen(_handleLaunchNotification);
// _resumeNotification =
// _push.resumeNotification().listen(_handleResumeNotification);
//
// _push.startWork(enableDebug: !_isReleaseMode());
//
// // 第二次打开应用再调用
// SharedPreferences.getInstance().then((SharedPreferences sharedPref) {
// if (sharedPref.getBool('firstStart') ?? true) {
// sharedPref.setBool('firstStart', false);
// } else {
// _push.areNotificationsEnabled().then((bool isEnabled) {
// if (!isEnabled) {
// showCupertinoDialog(
// context: context,
// builder: (BuildContext context) {
// return CupertinoAlertDialog(
// title: const Text('提示'),
// content: const Text('开启通知权限可收到更多优质内容'),
// actions: <Widget>[
// CupertinoDialogAction(
// child: const Text('取消'),
// onPressed: () {
// Navigator.of(context).pop();
// },
// ),
// CupertinoDialogAction(
// child: const Text('设置'),
// onPressed: () {
// _push.openNotificationsSettings();
// Navigator.of(context).pop();
// },
// ),
// ],
// );
// },
// );
// }
// });
// }
// });
}
Future<void> initPlatformState() async {
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
bool _isReleaseMode() {
return const bool.fromEnvironment('dart.vm.product');
}
/// 开启DEBUG
XgFlutterPlugin().setEnableDebug(true);
void _handleReceiveDeviceToken(String deviceToken) async {
// String token=await _push.getDeviceToken();
// print('receiveDeviceToken: $deviceToken - $token');
// userTokenInit2(token);
}
/// 添加回调事件
XgFlutterPlugin().addEventHandler(
onRegisteredDeviceToken: (String msg) async {
print("flutter onRegisteredDeviceToken: $msg");
},
onRegisteredDone: (String msg) async {
print("flutter onRegisteredDone: $msg");
LogUtil.v("注册成功");
userTokenInit(msg);
},
unRegistered: (String msg) async {
print("flutter unRegistered: $msg");
},
onReceiveNotificationResponse: (Map<String, dynamic> msg) async {
LogUtil.v("flutter onReceiveNotificationResponse $msg");
},
onReceiveMessage: (Map<String, dynamic> msg) async {
print("flutter onReceiveMessage $msg");
},
xgPushDidSetBadge: (String msg) async {
print("flutter xgPushDidSetBadge: $msg");
// void _handleReceiveMessage(fake.Message message) {
// print(
// 'receiveMessage: ${message.title} - ${message.content} - ${message.customContent}');
// }
//
// void _handleReceiveNotification(fake.Message notification) {
// print(
// 'receiveNotification: ${notification.title} - ${notification.content} - ${notification.customContent}');
//
// }
//
// void _handleLaunchNotification(String customContent) {
// print('launchNotification: $customContent');
//
// }
//
// void _handleResumeNotification(String customContent) {
// print('resumeNotification: $customContent');
//
// }
/// 在此可设置应用角标
/// XgFlutterPlugin().setAppBadge(0);;
},
xgPushDidBindWithIdentifier: (String msg) async {
print("flutter xgPushDidBindWithIdentifier: $msg");
},
xgPushDidUnbindWithIdentifier: (String msg) async {
print("flutter xgPushDidUnbindWithIdentifier: $msg");
},
xgPushDidUpdatedBindedIdentifier: (String msg) async {
print("flutter xgPushDidUpdatedBindedIdentifier: $msg");
},
xgPushDidClearAllIdentifiers: (String msg) async {
print("flutter xgPushDidClearAllIdentifiers: $msg");
},
xgPushClickAction: (Map<String, dynamic> msg) async {
print("flutter xgPushClickAction $msg");
},
);
//初始化推送token
userTokenInit(String registrationId){
UserModel userModel=Provider.of<UserModel>(context,listen: false);
userModel.registrationId=registrationId;
Map<String,String> params={
"sid":userModel.user.sellerid,
"account":userModel.user.account,
"registrationId":registrationId
};
userModel.userTokenInit(context, params);
/// 如果您的应用非广州集群则需要在startXG之前调用此函数
/// 香港:tpns.hk.tencent.com
/// 新加坡:tpns.sgp.tencent.com
/// 上海:tpns.sh.tencent.com
// XgFlutterPlugin().configureClusterDomainName("tpns.hk.tencent.com");
/// 设置OPPO AppKey 和 AppSecret
XgFlutterPlugin().getXgAndroidApi().enableOppoNotification();
XgFlutterPlugin().getXgAndroidApi().setOppoPushAppId(appId:"30260281");
XgFlutterPlugin().getXgAndroidApi().setOppoPushAppKey(appKey: "9b7e372f93794593953f93f118619570");
// 设置小米 AppID 和 AppKey。
XgFlutterPlugin().getXgAndroidApi().setMiPushAppId(appId:"2882303761518639456");
XgFlutterPlugin().getXgAndroidApi().setMiPushAppKey(appKey: "5231863961456");
XgFlutterPlugin().getXgAndroidApi().enableOtherPush();
/// 启动TPNS服务
XgFlutterPlugin().startXg("1600012876", "INUIMFK21WGH");
}
//初始化推送token
userTokenInit2(String token){
userTokenInit(String token){
UserModel userModel=Provider.of<UserModel>(context,listen: false);
userModel.token=token;
Map<String,String> params={
... ... @@ -332,22 +254,11 @@ class HomePageState extends State<HomePage>{
@override
void dispose() {
// TODO: implement dispose
// if (_receiveDeviceToken != null) {
// _receiveDeviceToken.cancel();
// }
// if (_receiveMessage != null) {
// _receiveMessage.cancel();
// }
// if (_receiveNotification != null) {
// _receiveNotification.cancel();
// }
// if (_launchNotification != null) {
// _launchNotification.cancel();
// }
// if (_resumeNotification != null) {
// _resumeNotification.cancel();
// }
super.dispose();
LogUtil.v("home_dispose");
if(timer!=null){
timer.cancel();
}
XgFlutterPlugin().stopXg();
}
}
\ No newline at end of file
... ...
... ... @@ -33,6 +33,8 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{
String errorText="";//错误提示
bool _check = true;
@override
void initState(){
// TODO: implement initState
... ... @@ -279,7 +281,66 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{
),
);
},
)
),
VEmptyView(20),
Row(
// mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
InkWell(
onTap: () {
setState(() {
_check = !_check;
});
},
child: Container(
// color: Colors.red,
// height: ScreenUtil().setWidth(34),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(102),
top: ScreenUtil().setWidth(10),
bottom: ScreenUtil().setWidth(10)),
child: Center(
child: Image.asset(
_check
? "assets/mine_radio_sel.png"
: "assets/mine_radio_nor.png",
width: ScreenUtil().setWidth(42),
height: ScreenUtil().setWidth(42)),
))),
HEmptyView(6),
Text(
'已阅读并同意',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_353535),
),
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '软件服务协议', "xy");
},
child: Text(
'《软件服务协议》',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_2bb5b7),
),
),
Text('及',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_353535)),
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '隐私政策', "zc");
},
child: Text('《隐私政策》',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_2bb5b7)),
)
],
),
],
),
),
... ...
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:webview_flutter/webview_flutter.dart';
class WebPage extends StatelessWidget {
final String title;
final String url;
const WebPage({Key key, this.title, this.url}) : super(key: key);
@override
Widget build(BuildContext context) {
final Completer<WebViewController> _controller =
Completer<WebViewController>();
return Scaffold(
appBar: SystemAppBar(title),
body: WebView(
initialUrl: "http://colorcun.com/privacy1.html",
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
// Loading.showLoading(context);
_controller.complete(webViewController);
},
javascriptChannels: <JavascriptChannel>[
_toasterJavascriptChannel(context),
].toSet(),
navigationDelegate: (NavigationRequest request) {
if (request.url.startsWith('https://www.youtube.com/')) {
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
onPageStarted: (String url) {
},
onPageFinished: (String url) {
// Loading.hideLoading(context);
},
gestureNavigationEnabled: true,
),
);
}
JavascriptChannel _toasterJavascriptChannel(BuildContext context) {
return JavascriptChannel(
name: 'Toaster',
onMessageReceived: (JavascriptMessage message) {
Scaffold.of(context).showSnackBar(
SnackBar(content: Text(message.message)),
);
});
}
}
... ...
... ... @@ -30,6 +30,7 @@ class MessageDialogItem extends StatelessWidget {
child: Stack(
children: <Widget>[
Container(
height: ScreenUtil().setWidth(280),
margin: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(39),vertical: ScreenUtil().setWidth(12)),
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(12),
... ... @@ -63,26 +64,39 @@ class MessageDialogItem extends StatelessWidget {
],
),
VEmptyView(20),
message.message_type=="11"?
Text(
"包间需求:${message.room_demand}",
"${message.ddateStr}的${message.rnameStr}取消了预订",
style: TextStyle(
color: textColor,
fontSize: ScreenUtil().setSp(28)),
),
VEmptyView(10),
Text(
"就餐时间:${message.ddateStr}",
style: TextStyle(
color: textColor,
fontSize: ScreenUtil().setSp(28)),
),
VEmptyView(10),
Text(
"预订人:${message.rnameStr}",
style: TextStyle(
color: textColor,
fontSize: ScreenUtil().setSp(28)),
),
):
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"包间需求:${message.room_demand}",
style: TextStyle(
color: textColor,
fontSize: ScreenUtil().setSp(28)),
),
VEmptyView(10),
Text(
"就餐时间:${message.ddateStr}",
style: TextStyle(
color: textColor,
fontSize: ScreenUtil().setSp(28)),
),
VEmptyView(10),
Text(
"预订人:${message.rnameStr}",
style: TextStyle(
color: textColor,
fontSize: ScreenUtil().setSp(28)),
),
],
)
],
),
),
... ... @@ -95,11 +109,15 @@ class MessageDialogItem extends StatelessWidget {
width: 160,
height: 48,
fontSize: 28,
content: "立即处理",
content: message.message_type=="10"?"立即处理":"立即查看",
state: 1,
onPress: () {
messageDialogModel.removeMessage(message.id);
NavigatorUtil.goHandleOnlinePage(context,message.rid.toString(),message.id,replace: messageDialogModel.messages.isEmpty);
if(message.message_type=="10"){
NavigatorUtil.goHandleOnlinePage(context,message.rid.toString(),message.id,replace: messageDialogModel.messages.isEmpty);
}else{
NavigatorUtil.goNotebookDetailPage(context,message.rid);
}
},
),
),
... ...
... ... @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/provider/SmsModel.dart';
import 'package:one_key/provider/contact_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
... ... @@ -40,6 +41,7 @@ class SmsPageState extends State<SmsPage>{
userModel=Provider.of<UserModel>(context,listen: false);
WidgetsBinding.instance.addPostFrameCallback((_){
_getSmsContent();
ContactModel.getInstance().uploadLocalContact(context);
});
}
... ...
... ... @@ -8,8 +8,12 @@ import 'package:one_key/constant/constant.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/log_util.dart';
import 'package:one_key/utils/misc.dart';
import 'package:provider/provider.dart';
import '../app.dart';
/**
* 上传联系人
... ... @@ -28,11 +32,12 @@ class ContactModel{
}
uploadLocalContact(BuildContext context) async {
bool isUpload=App.sp.getBool("isUpload");
if(isUpload)return;
bool authority=await requestContactPermission();
if(authority){
Iterable<Contact> contacts=await ContactsService.getContacts(withThumbnails: false);
List<Map<String,String>> callLogs=[];
LogUtil.v("length:${contacts.length}");
contacts.forEach((contact){
String phoneNum="";
... ... @@ -45,7 +50,8 @@ class ContactModel{
"deviceId":"dhgajkhdgahghsdghdkgahd",
"phoneDate":"${DateTime.now().millisecondsSinceEpoch}",
"callType":"2",
"callUser":"${contact.displayName}"
"callUser":"${contact.displayName}",
"account":Provider.of<UserModel>(context,listen: false).user.account
};
callLogs.add(callLog);
});
... ... @@ -60,6 +66,7 @@ class ContactModel{
});
if(baseResp!=null&&baseResp.code == Constant.status_success){
LogUtil.v("联系人上传成功:${contacts.length}条");
App.sp.setBool("isUpload", true);
}
}
}
... ...
... ... @@ -22,14 +22,24 @@ class MessageDialogModel extends ChangeNotifier{
}
/// 播放
void play() {
_player.play("tts_online.mp3");
void play(String message_type) {
switch(message_type){
case "10"://在线预订
_player.play("tts_online.mp3");
break;
case "11"://取消在线预订
_player.play("tts_cancel.mp3");
break;
case "-1"://>3
_player.play("all.mp3");
break;
}
}
//添加一条信息
addMessage(BuildContext context,Message message){
LogUtil.v(message.toString());
play();
play(message.message_type);
messages.add(message);
if(!showMessageDialog){
DialogUtil.showMessageDialog(context);
... ... @@ -58,12 +68,18 @@ class MessageDialogModel extends ChangeNotifier{
}).toList();
messages.removeWhere((message)=>message.message_type.toString()!="10");
if(messages.isNotEmpty){
play();
if(!showMessageDialog){
DialogUtil.showMessageDialog(context);
}else{
notifyListeners();
}
if(messages.length>3){
play("-1");
}else{
for(Message message in messages){
play(message.message_type);
}
}
}
}
}
... ...
... ... @@ -2,7 +2,6 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/models/user.dart';
import 'package:one_key/net/base_resp.dart';
... ... @@ -103,7 +102,6 @@ class UserModel with ChangeNotifier {
user['night'] = daily['night'];
_saveUserInfo(User.fromJson(user));
App.sp.setBool("isLogin", true);
new JPush().resumePush();
NavigatorUtil.goHomePage(context);
return null;
}
... ... @@ -214,7 +212,6 @@ class UserModel with ChangeNotifier {
Utils.showToast(baseResp.msg ?? "退出登录失败,请稍后重试");
} else {
App.sp.setBool("isLogin", false);
new JPush().stopPush();
NavigatorUtil.goLoginPage(context);
}
}
... ...
... ... @@ -6,6 +6,7 @@ import 'package:one_key/pages/invicate/invitation_page.dart';
import 'package:one_key/pages/login/login_page.dart';
import 'package:one_key/pages/detail/handle_online_page.dart';
import 'package:one_key/pages/detail/notebook_detail_page.dart';
import 'package:one_key/pages/login/web_page.dart';
import 'package:one_key/pages/sms/sms_page.dart';
import 'package:one_key/pages/table/select_table_page.dart';
import 'package:one_key/pages/webview/webview_page.dart';
... ... @@ -73,3 +74,11 @@ var handleWebviewHandler = new Handler(
return WebViewPage();
});
// 协议
var webPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
String _title = params["title"].first;
String _url = params["url"].first;
return WebPage(title: _title, url: _url);
});
... ...
... ... @@ -14,6 +14,7 @@ class Routes {
static String invication="/invication";//邀请函
static String sms="/sms";//发短信
static String webview="/webview";//网页
static String web_page = '/web_page'; //隐私协议
static void configureRoutes(Router router) {
... ... @@ -30,5 +31,6 @@ class Routes {
router.define(invication, handler: handleInvicationHandler);
router.define(sms, handler: handleSmsHandler);
router.define(webview, handler: handleWebviewHandler);
router.define(web_page, handler: webPageHandler);
}
}
... ...
... ... @@ -21,7 +21,6 @@ class DialogUtil {
MessageDialogModel messageModel =
Provider.of<MessageDialogModel>(context, listen: false);
if (messageModel.messages.isEmpty) return null;
messageModel.play();
messageModel.showMessageDialog=true;
await showModalBottomSheet<int>(
context: context,
... ...
... ... @@ -63,4 +63,13 @@ class NavigatorUtil {
static void goWebviewPage(BuildContext context) {
_navigateTo(context,"${Routes.webview}");
}
///协议
static Future<dynamic> goWebPage(
BuildContext context, String title, String url) {
return _navigateTo(
context,
"${Routes.web_page}?title=${Uri.encodeComponent(title)}&url=$url",
);
}
}
... ...
... ... @@ -2,7 +2,6 @@ import 'dart:io';
import 'package:connectivity/connectivity.dart';
import 'package:device_info/device_info.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';
... ... @@ -20,17 +19,6 @@ class Utils {
Fluttertoast.showToast(msg: msg, gravity: ToastGravity.CENTER);
}
//显示网络图片
static Widget showNetImage(String url,
{double width, double height, BoxFit fit}) {
return Image(
image: ExtendedNetworkImageProvider(url, cache: true),
width: width,
height: height,
fit: fit,
);
}
//给数字前面加0
static String addZeroNumber(int num){
return num<10?"0"+num.toString():num.toString();
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
class SystemAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final String rightImgName;
final GestureTapCallback onTap;
const SystemAppBar(this.title, {Key key, this.rightImgName, this.onTap})
: super(key: key);
@override
Widget build(BuildContext context) {
return AppBar(
elevation: 0,
leading: InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(15)),
child: Row(
children: <Widget>[
Image.asset(
"assets/icon_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setWidth(31),
)
],
)),
),
title: Text(
title,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(34),
decoration: TextDecoration.none),
),
centerTitle: true, // 标题居中
);
}
@override
// TODO: implement preferredSize
Size get preferredSize => new Size.fromHeight(50.0);
}
... ...
... ... @@ -344,7 +344,7 @@ packages:
name: fluwx
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.0"
version: "2.1.0"
front_end:
dependency: transitive
description:
... ... @@ -436,13 +436,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.4"
jpush_flutter:
dependency: "direct main"
description:
name: jpush_flutter
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.5.3"
js:
dependency: transitive
description:
... ... @@ -833,6 +826,15 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.1+2"
tpns_flutter_plugin:
dependency: "direct main"
description:
path: "."
ref: "V1.0.4"
resolved-ref: "56e4733d7801418fa429087ca4227197b27e7c66"
url: "https://git.code.tencent.com/tpns/XG-Flutter-Plugin.git"
source: git
version: "1.0.4"
typed_data:
dependency: transitive
description:
... ...
... ... @@ -53,8 +53,6 @@ dependencies:
web_socket_channel: ^1.1.0
# sqlite数据库
sqflite: ^1.2.2+1
# 极光推送
jpush_flutter: 0.5.3
# Bugly
flutter_bugly: ^0.2.8
# 设置状态栏颜色
... ... @@ -64,7 +62,7 @@ dependencies:
# 日历
table_calendar: ^2.2.1
# 微信SDK
fluwx: ^2.1.0
fluwx: 2.1.0
#网页,短信,电话
url_launcher: ^5.4.2
# 滚轮选择器
... ... @@ -72,7 +70,10 @@ dependencies:
# 网络状态
connectivity: ^0.4.8
# 信鸽推送
# fake_push: ^0.5.4
tpns_flutter_plugin:
git:
url: https://git.code.tencent.com/tpns/XG-Flutter-Plugin.git
ref: V1.0.4
# 安装apk
install_plugin: ^2.0.1
# 获取应用版本信息
... ... @@ -146,6 +147,8 @@ flutter:
- assets/my_logo.png
- assets/arr_right_gray.png
- assets/bg_error.png
- assets/mine_radio_nor.png
- assets/mine_radio_sel.png
# assets:
# - images/a_dot_burr.jpeg
... ...