---
title: Stop an interaction
source: https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/stop-interaction
---

## Android

### Syntax [#syntax]

#### Java [#java]

```java
NewRelic.endInteraction(string $interactionID)
```

#### Kotlin [#kotlin]

```kotlin
NewRelic. endInteraction(id : String!)
```

### Description [#description]

New Relic ends all interactions automatically, but you can use `endInteraction()` to end a custom interaction early. The string ID is returned when you use the `startInteraction()` call.

This call has no effect if the interaction has already ended.

### Parameters [#parameters]

| Parameter       | Type     | Description                                                                                                                        |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `interactionID` | `string` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

Here's an example of ending a custom interaction `RefreshContacts`:

#### Java [#java]

```java
public class MainActivity extends Activity {
  ...
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.action_refresh:
        String interactionId = NewRelic.startInteraction("RefreshContacts");
        ...
        return true;
      default:
        NewRelic.endInteraction(interactionId);
        return super.onOptionsItemSelected(item);
    }
  }
  ...
}
```

## iOS

### Syntax [#syntax]

#### Objective-c [#objc]

```objectivec
+ (void) stopCurrentInteraction:(NSString*)interactionIdentifier;
```

#### Swift [#swift]

```swift
NewRelic.stopInteraction(string: "myInteractionName")
```

### Description [#description]

This method will stop the interaction trace associated with the `interactionIdentifier` (which is returned by the `startInteractionWithName: ` method). It's not necessary to call this method to complete an interaction trace (an interaction trace will intelligently complete on its own). However, use this method if you want a more discrete interaction period.

### Parameters [#parameters]

| Parameter               | Type     | Description                                                                                                                                  |
| ----------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `interactionIdentifier` | `string` | Required. The value returned by `startInteractionWithName: `. It is required to pass this string to manually complete the interaction trace. |

### Examples [#examples]

#### Objective-C [#obj-c]

```objectivec
NSString *identifier = [NewRelic startInteractionWithName: @"myInteractionName"];
[NewRelic stopCurrentInteraction: identifier];
```

#### Swift [#swift]

```swift
let identifier = NewRelic.startInteraction(withName: "myInteractionName")
NewRelic.stopCurrentInteraction(identifier)
```

## Capacitor

### Syntax [#syntax]

```typescript
endInteraction(options: { interactionId: string; }) => void
```

### Description [#description]

This uses the string ID for the interaction you want to end. This string is returned when you use [`startInteraction()`](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/start-interaction).

### Parameters [#parameters]

| Parameter       | Type     | Description                                                                                                                        |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `interactionID` | `string` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

```typescript
const badApiLoad = async () => {
  const id = await NewRelicCapacitorPlugin.startInteraction({ value: 'StartLoadBadApiCall' });
  console.log(id);
  const url = 'https://fakewebsite.com/moviessssssssss.json';
  fetch(url)
    .then((response) => response.json())
    .then((responseJson) => {
      console.log(responseJson);
      NewRelicCapacitorPlugin.endInteraction({ interactionId: id.value });
    }) 
    .catch((error) => {
      NewRelicCapacitorPlugin.endInteraction({ interactionId: id.value });
      console.error(error);
    });
};
```

## Cordova

### Syntax [#syntax]

```typescript
endInteraction(id: InteractionId): void;
```

### Description [#description]

This uses the string ID for the interaction you want to end. This string is returned when you use [`startInteraction()`](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/start-interaction).

### Parameters [#parameters]

| Parameter | Type            | Description                                                                                                                        |
| --------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `id`      | `InteractionId` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

```js
const badApiLoad = async () => {
  const interactionId = await NewRelic.startInteraction('StartLoadBadApiCall');
  console.log(interactionId);
  const url = 'https://cordova.apache.org/moviessssssssss.json';
  fetch(url)
    .then((response) => response.json())
    .then((responseJson) => {
      console.log(responseJson);
      NewRelic.endInteraction(interactionId);
    }) 
    .catch((error) => {
      NewRelic.endInteraction(interactionId);
      console.error(error);
    });
```

## .NET MAUI

### Syntax [#syntax]

```csharp
EndInteraction(string interactionId): void;
```

### Description [#description]

This uses the string ID for the interaction you want to end. This string is returned when you use [`startInteraction()`](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/start-interaction).

### Parameters [#parameters]

| Parameter       | Type     | Description                                                                                                                        |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `interactionId` | `string` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

```csharp
HttpClient myClient = new HttpClient(CrossNewRelic.Current.GetHttpMessageHandler());
string interactionId = CrossNewRelic.Current.StartInteraction("Getting data from service");
var response = await myClient.GetAsync(new Uri("https://jsonplaceholder.typicode.com/todos/1"));

if (response.IsSuccessStatusCode)
{
    var content = await response.Content.ReadAsStringAsync();
} 
else
{
    Console.WriteLine("Unsuccessful response code");
}

CrossNewRelic.Current.EndInteraction(interactionId);
```

## Flutter

### Syntax [#syntax]

```dart
endInteraction(String interactionId): void;
```

### Description [#description]

This uses the string ID for the interaction you want to end. This string is returned when you use [`startInteraction()`](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/start-interaction).

### Parameters [#parameters]

| Parameter       | Type     | Description                                                                                                                        |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `interactionId` | `string` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

```dart
var id = await NewrelicMobile.instance.startInteraction("Getting Data from Service");

try {
  var dio = Dio();
  var response = await dio.get(
    'https://reqres.in/api/users?delay=15');
    print(response);
    NewrelicMobile.instance.endInteraction(id);
    Timeline.finishSync();
} catch (e) {
  print(e);
}
```

## React Native

### Syntax [#syntax]

```ts
endInteraction(id: InteractionId): void;
```

### Description [#description]

This uses the string ID for the interaction you want to end. This string is returned when you use [`startInteraction()`](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/start-interaction).

### Parameters [#parameters]

| Parameter       | Type     | Description                                                                                                                        |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `InteractionID` | `string` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

```js
const badApiLoad = async () => {
  const interactionId = await NewRelic.startInteraction('StartLoadBadApiCall');
  console.log(interactionId);
  const url = 'https://facebook.github.io/react-native/moviessssssssss.json';
  fetch(url)
    .then((response) => response.json())
    .then((responseJson) => {
      console.log(responseJson);
      NewRelic.endInteraction(interactionId);
    })
    .catch((error) => {
      NewRelic.endInteraction(interactionId);
      console.error(error);
    });;
};
```

## Unity

### Syntax [#syntax]

```csharp
StopCurrentInteraction(string interactionId): void;
```

### Description [#description]

This uses the string ID for the interaction you want to end. This string is returned when you use [`startInteraction()`](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/start-interaction).

### Parameters [#parameters]

| Parameter       | Type     | Description                                                                                                                        |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `interactionId` | `string` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

```csharp
string interActionId = NewRelicAgent.StartInteractionWithName("Unity InterAction Example");

for(int i =0; i < 4;i++)
{
    Thread.Sleep(1000);
}

NewRelicAgent.StopCurrentInteraction(interActionId);
```

## Unreal Engine

### Syntax [#syntax]

```csharp
endInterAction(FString interActionId): void;
```

### Description [#description]

This uses the string ID for the interaction you want to end. This string is returned when you use [`startInteraction()`](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/start-interaction).

### Parameters [#parameters]

| Parameter       | Type      | Description                                                                                                                        |
| --------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `interactionId` | `FString` | Required. The value returned by `startInteraction`. It is required to pass this string to manually complete the interaction trace. |

### Example [#example]

```cpp
#include "NewRelicBPLibrary.h"

FString id =  UNewRelicBPLibrary::startInterAction("test Unreal InterAction");

FPlatformProcess::Sleep(6.0);

UNewRelicBPLibrary::endInterAction(id);
```

![Screenshot of the Unreal Engine Plugin Stop InterAction](https://docs.newrelic.com/images/newrelic_unreal_sdk_interaction_example.webp "Unreal Engine Plugin Stop InterAction")
