unit uDeviceID;
interface
Uses
FMX.
platform,
{$IFDEF ANDROID}
fmx.helpers.android, androidapi.JNI.GraphicsContentViewText, androidapi.jni.JavaTypes,
androidapi.helpers,androidapi.jni.App, androidapi.jni.Net, androidapi.JNIBridge,
androidapi.JNI.Provider,
{$ENDIF}
{$IFDEF IOS}
Macapi.Helpers, iOSapi.UIKit,
{$ENDIF}
classes, Types, FMX.types, system.Messaging, FMX.Dialogs, FMX.Forms;
type
TDeviceIdentifier =
class(TComponent)
private
{$IFDEF ANDROID}
WifiManagerObj: JObject;
WifiManager: JWifiManager;
WifiInfo: JWifiInfo;
{$ENDIF}
{$IFDEF IOS}
fUIDevice : UIDevice;
{$ENDIF}
FWifiMacAdresse:
String;
fDeviceID:
String;
function GetID:
String;
public
Constructor Create(aOwner:TComponent);
property ID:
String read GetID;
end;
implementation
{ TDeviceIdentifier }
constructor TDeviceIdentifier.Create(aOwner: TComponent);
begin
inherited;
{$IFDEF ANDROID}
WifiManagerObj := SharedActivityContext.getSystemService(TJContext.JavaClass.WIFI_SERVICE);
WifiManager := TJWifiManager.Wrap((WifiManagerObj
as ILocalObject).GetObjectID);
WifiInfo := WifiManager.getConnectionInfo();
FWifiMacAdresse := JStringToString(WifiInfo.getMacAddress);
fDeviceID := JStringToString(TJSettings_SECURE.JavaClass.getString(SharedActivity.getContentResolver, TJSettings_SECURE.JavaClass.ANDROID_ID));
{$ENDIF}
{$IFDEF IOS}
fUIDevice := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
fDeviceID := NSStrToStr(fUIDevice.identifierForVendor.UUIDString);
{$ENDIF}
end;
function TDeviceIdentifier.GetID:
String;
begin
Result := fDeviceID+FWifiMacAdresse;
if result = '
'
then
Begin
Showmessage('
Dieses Gerät wird nicht von der App unterstützt!');
Application.terminate;
End;
end;
end.