Browse Source

1.开屏广告

tags/0.0.18
“yanghuaxuan” 3 years ago
parent
commit
318359db05
2 changed files with 18 additions and 11 deletions
  1. +6
    -0
      lib/pages/home_page/home_page.dart
  2. +12
    -11
      lib/pages/launch_page/launch_page.dart

+ 6
- 0
lib/pages/home_page/home_page.dart View File

@@ -70,6 +70,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
@override @override
void initState() { void initState() {
///初始化一些数据 ///初始化一些数据

initAsync(); initAsync();


//如果登出则重新打开首页 //如果登出则重新打开首页
@@ -93,6 +94,11 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
///初始化各种监听 ///初始化各种监听
initAsync() async { initAsync() async {
try { try {
Future.delayed(Duration(milliseconds: 10), () async {
GlobalConfig.context = context;
await AdvertisingUtils.openSplashAd();
});

WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);


// mob锁粉隐私协议提交 // mob锁粉隐私协议提交


+ 12
- 11
lib/pages/launch_page/launch_page.dart View File

@@ -26,6 +26,7 @@ import 'package:zhiying_comm/util/shared_prefe_util.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:zhiying_comm/util/update/app_update_util.dart'; import 'package:zhiying_comm/util/update/app_update_util.dart';

// 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题 // 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题
class LaunchPage extends StatefulWidget { class LaunchPage extends StatefulWidget {
final WidgetBuilder builder; final WidgetBuilder builder;
@@ -57,19 +58,20 @@ class _LaunchPageState extends State<LaunchPage> with TickerProviderStateMixin {
///检查是否覆盖安装 ///检查是否覆盖安装
//取masterId //取masterId


String lasterMasterId = await SharedPreferencesUtil.getStringValue(Constants.masterId, defaultVal: "1");
Map setting = await NativeUtil.getSetting();
String masterId = setting['master_id'];
if (lasterMasterId != "1") {
if (masterId != lasterMasterId) {
await SharedPreferencesUtil.clean();
}
String lasterMasterId = await SharedPreferencesUtil.getStringValue(Constants.masterId, defaultVal: "1");
Map setting = await NativeUtil.getSetting();
String masterId = setting['master_id'];
if (lasterMasterId != "1") {
if (masterId != lasterMasterId) {
await SharedPreferencesUtil.clean();
} }
SharedPreferencesUtil.setStringValue(Constants.masterId, masterId);


}
SharedPreferencesUtil.setStringValue(Constants.masterId, masterId);


Application.init().then((_) async { Application.init().then((_) async {
///初始化广告SDK
await AdvertisingUtils.init();

///引导页 ///引导页
PackageInfo packageInfo = await PackageInfo.fromPlatform(); PackageInfo packageInfo = await PackageInfo.fromPlatform();
String versionNumber = await SharedPreferencesUtil.getStringValue(Constants.versionNumber); String versionNumber = await SharedPreferencesUtil.getStringValue(Constants.versionNumber);
@@ -86,7 +88,6 @@ class _LaunchPageState extends State<LaunchPage> with TickerProviderStateMixin {
// CupertinoPageRoute(builder: (context) => HomePage())); // CupertinoPageRoute(builder: (context) => HomePage()));
print("打开首页"); print("打开首页");
Navigator.of(context).pushReplacementNamed('/homePage'); Navigator.of(context).pushReplacementNamed('/homePage');

} }
}).catchError((err, s) async { }).catchError((err, s) async {
print(s); print(s);


Loading…
Cancel
Save