-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathFMX.ZDeviceInfo.iOS.pas
More file actions
123 lines (98 loc) · 2.84 KB
/
FMX.ZDeviceInfo.iOS.pas
File metadata and controls
123 lines (98 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
unit FMX.ZDeviceInfo.iOS;
interface
uses
FMX.Platform, FMX.ZDeviceInfo,
FMX.PhoneDialer_iOSfix,
FMX.PhoneDialer;
type
TZiOSDeviceInfo = class(TInterfacedObject, IZDeviceInfoService)
{ IZDeviceInfoService }
function PlatformVer: string;
function Architecture2: string;
function Device: string;
function MacAddress: string;
function IPAddress: string;
function MobileOperator: string;
function IsIntel: Boolean;
function IsNetConnected: Boolean;
function NetworkConnectionType: TZNetworkConnectionType;
function MobileDataType: TZMobileDataType;
function IsGPSActive(HIGH_ACCURACY: Boolean = false): Boolean;
function DeviceID: string;
end;
procedure RegisterService;
procedure UnregisterService;
implementation
{ TZiOSDeviceInfo }
uses
System.SysUtils,
System.NetEncoding,
iOSapi.CocoaTypes, iOSapi.Foundation, iOSapi.UIKit, FMX.Helpers.iOS;
function TZiOSDeviceInfo.Architecture2: string;
begin
Result := '';
end;
function TZiOSDeviceInfo.Device: string;
begin
with TUIDevice.Wrap(TUIDevice.OCClass.currentDevice) do
Result := model.UTF8String;
end;
function TZiOSDeviceInfo.DeviceID: string;
begin
with TUIDevice.Wrap(TUIDevice.OCClass.currentDevice) do
Result := AnsiLowerCase(TNetEncoding.Base64.Encode(identifierForVendor.UUIDString.UTF8String));
end;
function TZiOSDeviceInfo.IPAddress: string;
begin
Result := 'unknown';
end;
function TZiOSDeviceInfo.IsGPSActive(HIGH_ACCURACY: Boolean): Boolean;
begin
Result := false; // ???
end;
function TZiOSDeviceInfo.IsIntel: Boolean;
begin
Result := TOSVersion.Architecture in [arIntelX86, arIntelX64];
end;
function TZiOSDeviceInfo.IsNetConnected: Boolean;
begin
Result := true; // ???
end;
function TZiOSDeviceInfo.MacAddress: string;
begin
Result := '02:00:00:00:00:00';
end;
function TZiOSDeviceInfo.MobileOperator: string;
var
aPhoneService: IFMXPhoneDialerService;
begin
Result := 'unknown';
{$IFDEF CPUARM}
if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(aPhoneService)) then
Result := aPhoneService.GetCarrier.GetCarrierName + ' ' + aPhoneService.GetCarrier.GetMobileCountryCode;
{$ENDIF}
end;
function TZiOSDeviceInfo.NetworkConnectionType: TZNetworkConnectionType;
begin
Result := TZNetworkConnectionType.Unknown;
end;
function TZiOSDeviceInfo.MobileDataType: TZMobileDataType;
begin
Result := TZMobileDataType.Unknown;
end;
function TZiOSDeviceInfo.PlatformVer: string;
begin
with TUIDevice.Wrap(TUIDevice.OCClass.currentDevice) do
begin
Result := systemName.UTF8String + ' (' + systemVersion.UTF8String + ')';
end;
end;
procedure RegisterService;
begin
TPlatformServices.Current.AddPlatformService(IZDeviceInfoService, TZiOSDeviceInfo.Create);
end;
procedure UnregisterService;
begin
TPlatformServices.Current.RemovePlatformService(IZDeviceInfoService);
end;
end.