DelphiでiOSの端末の情報を取得する

実行中の端末がiPhoneとiPadのどちらであるかを取得する

FMX.Helpers.iOSユニットにあるIsPhone関数とIsPadを使用します。

uses
  FMX.Helpers.iOS;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if IsPhone then
    ShowMessage('iPhoneです');
  if IsPad then
    ShowMessage('iPadです');
end;

Simulator Screen Shot 2016.06.18 23.13.25

Simulator Screen Shot 2016.06.18 23.17.50

モデル(機種名)や名前、バージョンを取得する

TUIDeviceで端末の情報を取得できます。

uses
  iOSapi.UIKit;

procedure TForm1.Button1Click(Sender: TObject);
var
  Model, Name, LocalizedModel, SystemName, SystemVersion: string;
begin
  // デバイスのモデル
  Model := UTF8ToString(TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).model.UTF8String);
  Memo1.Lines.Add('Model=' + Model);

  // デバイスの名前
  Name := UTF8ToString(TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).name.UTF8String);
  Memo1.Lines.Add('Name=' + Name);

  // デバイスのローカルバージョン
  LocalizedModel := UTF8ToString(TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).localizedModel.UTF8String);
  Memo1.Lines.Add('LocalizedModel=' + LocalizedModel);

  // OS名
  SystemName := UTF8ToString(TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).systemName.UTF8String);
  Memo1.Lines.Add('SystemName=' + SystemName);

  // OS名
  SystemVersion := UTF8ToString(TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).systemVersion.UTF8String);
  Memo1.Lines.Add('SystemVersion=' + SystemVersion);
end;

取得出来るモデルは次のようになります。

  • iPhone
  • iPod touch
  • iPad
  • iPhone Simulator

Simulator Screen Shot 2016.06.19 11.30.05

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください