Parcourir la source

0106 推送集成

tags/0.0.3+6
23028876916@qq.com il y a 3 ans
committed by “yanghuaxuan”
Parent
révision
f922065409
10 fichiers modifiés avec 54 ajouts et 30 suppressions
  1. BIN
     
  2. BIN
     
  3. BIN
     
  4. BIN
     
  5. BIN
     
  6. +28
    -28
      example/android/app/build.gradle
  7. +1
    -0
      example/lib/main.dart
  8. +17
    -0
      lib/pages/home_page/home_page.dart
  9. +7
    -0
      lib/pages/launch_page/launch_page.dart
  10. +1
    -2
      lib/utils/mob_push_util.dart





+ 28
- 28
example/android/app/build.gradle Voir le fichier

@@ -107,34 +107,34 @@ android {
}


//应用信息配置
productFlavors {
// 智夜生活
zhiying {
applicationId "cn.zhios.zhiying"
versionCode 25
dimension "app"
versionName '1.2.5'
// 签名信息
signingConfig signingConfigs.zhiying
}
}
// 打包脚本
android.applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
}
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
//这里修改apk文件名
def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
outputFileName = fileName
}
}
}
// 应用信息配置
// productFlavors {
// // 智夜生活
// zhiying {
// applicationId "cn.zhios.zhiying"
// versionCode 22
// dimension "app"
// versionName '1.2.2'
// // 签名信息
// signingConfig signingConfigs.zhiying
// }
// }
//
// // 打包脚本
// android.applicationVariants.all { variant ->
// if (variant.buildType.name != "debug") {
// variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
// }
//
// variant.outputs.all { output ->
// def outputFile = output.outputFile
// if (outputFile != null && outputFile.name.endsWith('.apk')) {
// //这里修改apk文件名
// def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
// outputFileName = fileName
// }
// }
// }

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->


+ 1
- 0
example/lib/main.dart Voir le fichier

@@ -53,6 +53,7 @@ class _MyAppState extends State<MyApp> {
FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
print("白川" + '${result.errorCode} ${result.errorMessage}');
});
MobPushUtil.setCanPush();


// app更新插件


+ 17
- 0
lib/pages/home_page/home_page.dart Voir le fichier

@@ -32,6 +32,9 @@ import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_comm/util/event_util/login_success_event.dart';
import 'package:zhiying_comm/util/event_util/event_util.dart';
import 'package:zhiying_comm/util/event_util/log_out.dart';
import 'package:zhiying_comm/util/event_util/login_success_event.dart';
import 'package:zhiying_comm/util/event_util/event_util.dart';
import 'package:zhiying_comm/util/event_util/log_out.dart';
import 'package:package_info/package_info.dart';

class HomePage extends StatefulWidget {
@@ -118,6 +121,19 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
// 监听开始(传递监听到原生端,用户监听场景还原的数据回传回来)
_eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);

MobPushUtil.addPushReceiver();
EventUtil.instance.on<LoginSuccessEvent>().listen((event) {
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo;
Logger.log("我的TOKEN5: " + userInfo?.userId);
if (!EmptyUtil.isEmpty(userInfo.userId)) {
MobPushUtil.setAlias(userInfo.userId);
}
});

EventUtil.instance.on<LogOut>().listen((event) {
MobPushUtil.deleteAlias();
});
super.initState();
MobPushUtil.addPushReceiver();
EventUtil.instance.on<LoginSuccessEvent>().listen((event) async {
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo;
@@ -138,6 +154,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
}
}


@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);


+ 7
- 0
lib/pages/launch_page/launch_page.dart Voir le fichier

@@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:async';
import 'dart:typed_data';

@@ -5,6 +6,9 @@ import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mobpush_plugin/mobpush_custom_message.dart';
import 'package:mobpush_plugin/mobpush_notify_message.dart';
import 'package:mobpush_plugin/mobpush_plugin.dart';
import 'package:flutter/services.dart';
import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart';
import 'package:mobpush_plugin/mobpush_custom_message.dart';
@@ -21,6 +25,7 @@ import 'package:zhiying_comm/util/shared_prefe_util.dart';
import 'package:package_info/package_info.dart';
import 'package:fluttertoast/fluttertoast.dart';


// 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题
class LaunchPage extends StatefulWidget {
final WidgetBuilder builder;
@@ -31,6 +36,8 @@ class LaunchPage extends StatefulWidget {
_LaunchPageState createState() => _LaunchPageState();
}

class _LaunchPageState extends State<LaunchPage> {
final GlobalKey navigatorKey = new GlobalKey();
class _LaunchPageState extends State<LaunchPage> with TickerProviderStateMixin {
final GlobalKey navigatorKey = new GlobalKey();



+ 1
- 2
lib/utils/mob_push_util.dart Voir le fichier

@@ -102,8 +102,7 @@ class MobPushUtil {
//设置远程推送环境,向用户授权(仅 iOS)
MobpushPlugin.setCustomNotification();
// 开发环境 false, 线上环境 true
const bool inProduction = const bool.fromEnvironment("dart.vm.product");
MobpushPlugin.setAPNsForProduction(inProduction);
MobpushPlugin.setAPNsForProduction(true);
}
//上传隐私协议许可
MobpushPlugin.updatePrivacyPermissionStatus(true);


Chargement…
Annuler
Enregistrer