mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00
ios: Check if running on a physcial device
Accordingly we switch off analytics.
This commit is contained in:
19
lib/app.dart
19
lib/app.dart
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:device_info/device_info.dart';
|
import 'package:device_info/device_info.dart';
|
||||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||||
import 'package:firebase_analytics/observer.dart';
|
import 'package:firebase_analytics/observer.dart';
|
||||||
@ -70,17 +72,26 @@ class JournalApp extends StatelessWidget {
|
|||||||
// Check if in debugMode or not a real device
|
// Check if in debugMode or not a real device
|
||||||
//
|
//
|
||||||
assert(JournalApp.isInDebugMode = true);
|
assert(JournalApp.isInDebugMode = true);
|
||||||
|
|
||||||
|
var isPhysicalDevice = true;
|
||||||
try {
|
try {
|
||||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
if (Platform.isAndroid) {
|
||||||
if (androidInfo.isPhysicalDevice == false) {
|
var info = await deviceInfo.androidInfo;
|
||||||
print("Not running in a physcial device");
|
isPhysicalDevice = info.isPhysicalDevice;
|
||||||
JournalApp.isInDebugMode = true;
|
} else if (Platform.isIOS) {
|
||||||
|
var info = await deviceInfo.iosInfo;
|
||||||
|
isPhysicalDevice = info.isPhysicalDevice;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPhysicalDevice == false) {
|
||||||
|
print("Not running in a physcial device");
|
||||||
|
JournalApp.isInDebugMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool should = (JournalApp.isInDebugMode == false);
|
bool should = (JournalApp.isInDebugMode == false);
|
||||||
should = should && (await shouldEnableAnalytics());
|
should = should && (await shouldEnableAnalytics());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user