# ユーティリティ

Monaca で提供している、他の関数を紹介します。

| メソッド/プロパティ                                                                  | 解説                          |
| --------------------------------------------------------------------------- | --------------------------- |
| [monaca.getDeviceId()](/reference/monaca_api/utility.md#monaca-getdeviceid) | 一意のデバイス ID を取得します。          |
| [monaca.baseUrl](/reference/monaca_api/utility.md#monaca-baseurl)           | `www` フォルダーへの絶対 URL を取得します。 |
| [monaca.isAndroid](/reference/monaca_api/utility.md#monaca-isandroid)       | Android 端末かどうか判別します。        |
| [monaca.isIOS](/reference/monaca_api/utility.md#monaca-isios)               | iOS 端末かどうか判別します。            |

## monaca.getDeviceId()

一意のデバイス ID を取得します。

{% hint style="info" %}
Monaca フレームワークでは、アプリの初回起動時に、一意のデバイス ID を自動的に生成します。
{% endhint %}

```bash
monaca.getDeviceId(callback)
```

**パラメーター**

| パラメーター     | 型  | 解説                           |
| ---------- | -- | ---------------------------- |
| `callback` | 関数 | コールバック関数です。第一引数は、デバイス ID です。 |

**戻り値**

* なし

**例**

```javascript
monaca.getDeviceId(function(id){
   console.log('Device ID: ' + id);
});
```

## monaca.baseUrl

`www` フォルダーへの絶対 URL を取得します。

```bash
monaca.baseUrl
```

**戻り値**

| 型   | 解説             |
| --- | -------------- |
| 文字列 | アプリの絶対 URL です。 |

**例**

```javascript
window.onload = function()
{
   alert(monaca.baseUrl);
}
```

## monaca.isAndroid

Android 端末 かどうかを判別します。

```bash
monaca.isAndroid
```

**戻り値**

| 型       | 解説                            |
| ------- | ----------------------------- |
| boolean | Android 端末であれば、 `true` を返します。 |

**例**

```javascript
if(monaca.isAndroid === true){
  alert("Android!");
}
```

## monaca.isIOS

iOS 端末かどうかを判別します。

```bash
monaca.isIOS
```

**戻り値**

| 型       | 解説                        |
| ------- | ------------------------- |
| boolean | iOS 端末であれば、 `true` を返します。 |

**例**

```javascript
if(monaca.isIOS === true){
  alert("iOS!");
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ja.docs.monaca.io/reference/monaca_api/utility.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
