Commit 46f3e142432bc74f804b9bcd487a3d69117aa63f

Authored by gaiyaguang
1 parent b1337589

安卓打包,去除fake_push

... ... @@ -41,7 +41,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.naji.one_key"
minSdkVersion 17
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
... ...
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.naji.one_key">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
... ... @@ -8,6 +9,7 @@
<application
android:name="io.flutter.app.FlutterApplication"
android:label="一键订"
tools:replace="android:label"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
... ...
import 'dart:async';
import 'dart:convert';
import 'package:fake_push/fake_push.dart' as fake;
//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';
... ... @@ -39,12 +39,12 @@ 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;
// 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();
... ... @@ -124,53 +124,53 @@ class HomePageState extends State<HomePage>{
//初始化信鸽推送
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();
},
),
],
);
},
);
}
});
}
});
// _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();
// },
// ),
// ],
// );
// },
// );
// }
// });
// }
// });
}
bool _isReleaseMode() {
... ... @@ -178,31 +178,31 @@ class HomePageState extends State<HomePage>{
}
void _handleReceiveDeviceToken(String deviceToken) async {
String token=await _push.getDeviceToken();
print('receiveDeviceToken: $deviceToken - $token');
userTokenInit2(token);
}
void _handleReceiveMessage(fake.Message message) {
print(
'receiveMessage: ${message.title} - ${message.content} - ${message.customContent}');
// String token=await _push.getDeviceToken();
// print('receiveDeviceToken: $deviceToken - $token');
// userTokenInit2(token);
}
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');
}
// 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');
//
// }
//初始化推送token
userTokenInit(String registrationId){
... ... @@ -326,21 +326,21 @@ 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();
}
// 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");
}
... ...
... ... @@ -218,13 +218,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.0"
fake_push:
dependency: "direct main"
description:
name: fake_push
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.5.4"
fixnum:
dependency: transitive
description:
... ... @@ -387,13 +380,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.3"
jaguar_serializer:
dependency: transitive
description:
name: jaguar_serializer
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.12"
jpush_flutter:
dependency: "direct main"
description:
... ...
... ... @@ -72,7 +72,7 @@ dependencies:
# 网络状态
connectivity: ^0.4.8
# 信鸽推送
fake_push: ^0.5.4
# fake_push: ^0.5.4
dev_dependencies:
flutter_test:
... ...