---
name: "registerGeofence"
mode: "kit"
deprecated: true
versionRequirements:
  - { name: "MapKit", version: "3.0.1" }
  - { name: "@ray-js/ray", version: "1.2.10" }
platform:
  - "iOS"
  - "Android"
async: true
title: "map.registerGeofence"
---

## registerGeofence

> [DEPRECATED] **Deprecated**: register

> [VERSION] MapKit >= 3.0.1 | @ray-js/ray >= 1.2.10

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Register a geofence. Permission: [scope.location]

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `geoTitle` | `string` | No | - | `3.9.1` | Geofence name |
| `longitude` | `number` | No | `0.0` | `3.9.1` | Longitude |
| `latitude` | `number` | No | `0.0` | `3.9.1` | Latitude |
| `radius` | `number` | No | `0` | `3.9.1` | Radius |
| `geofenceId` | `string` | No | - | `3.9.1` | id |
| `type` | `number` | No | `0` | `3.9.1` | Radius 0: enter geofence 1: leave geofence |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `() => void` | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Examples

#### Basic call

```tsx
import { map } from '@ray-js/ray'

const { registerGeofence } = map;

registerGeofence({
  geoTitle: 'home',
  longitude: 120.15,
  latitude: 30.27,
  radius: 500,
  geofenceId: 'fence_001',
  type: 0,
  success: () => {
    console.log('registerGeofence success');
  },
  fail: (error) => {
    console.log('registerGeofence fail', error.errorMsg);
  },
});
```
