# API reference

> Every public type, property and method in the Grovs Flutter plugin 3.1.1.

Source: https://docs.grovs.io/docs/sdk/flutter/api-reference

`Grovs()` is cheap: every instance talks to the same native SDK. Every method returns a `Future` that completes once the native SDK has the call, unless noted.

## Imports

```dart
import 'package:grovs_flutter_plugin/grovs.dart';
import 'package:grovs_flutter_plugin/models/grovs_link.dart';
import 'package:grovs_flutter_plugin/grovs_navigator_observer.dart';
```

| Import                          | Provides                                                                               |
| ------------------------------- | -------------------------------------------------------------------------------------- |
| `grovs.dart`                    | `Grovs`, every method on this page, and the [in-app message types](#inappmessageevent) |
| `models/grovs_link.dart`        | Parameter and result [types](#types)                                                   |
| `grovs_navigator_observer.dart` | [`GrovsNavigatorObserver`](#grovsnavigatorobserver)                                    |

## At a glance

| Area                   | Member                                                  | Kind         | What it does                           |
| ---------------------- | ------------------------------------------------------- | ------------ | -------------------------------------- |
| **Setup**              | [Native configuration keys](#native-configuration-keys) | type         | API key and options, set natively      |
|                        | [`setSDK`](#setsdk)                                     | method       | Turns collection on or off             |
|                        | [`setDebugLevel`](#setdebuglevel)                       | method       | Sets the native log level              |
|                        | [`onError`](#onerror)                                   | property     | Stream of SDK errors (iOS)             |
|                        | [`getPlatformVersion`](#getplatformversion)             | method       | Host OS version                        |
| **Deep links**         | [`onDeeplinkReceived`](#ondeeplinkreceived)             | property     | Stream of resolved links and push taps |
|                        | [`handleUrl`](#handleurl)                               | method       | Resolves a link tapped inside your app |
| **Users**              | [`setUserIdentifier`](#setuseridentifier)               | method       | Sets your ID for the user              |
|                        | [`setUserAttributes`](#setuserattributes)               | method       | Sets user attributes                   |
| **Links**              | [`generateLink`](#generatelink)                         | method       | Creates a smart link                   |
|                        | [`linkDetails`](#linkdetails)                           | method       | Gets a link's details by path          |
| **Events**             | [`track`](#track)                                       | method       | Tracks a custom event                  |
|                        | [`trackScreenView`](#trackscreenview)                   | method       | Tracks a screen view                   |
|                        | [`navigatorObserver`](#navigatorobserver)               | property     | Automatic screen tracking              |
|                        | [`setGlobalTags`](#setglobaltags)                       | method       | Tags added to every event              |
|                        | [`setScreenAliases`](#setscreenaliases)                 | method       | Renames screens for the dashboard      |
|                        | [`screenAliases`](#screenaliases)                       | property     | Aliases last set                       |
| **Revenue**            | [`logInAppPurchase`](#loginapppurchase)                 | method       | Logs a store purchase                  |
|                        | [`logCustomPurchase`](#logcustompurchase)               | method       | Logs a purchase outside the store      |
| **Push notifications** | [`setPushToken`](#setpushtoken)                         | method       | Sets the APNs or FCM token             |
|                        | [`isGrovsNotification`](#isgrovsnotification)           | method       | Checks whether Grovs sent a push       |
|                        | [`handleNotificationOpen`](#handlenotificationopen)     | method       | Counts a tap and opens the push's link |
| **In-app messages**    | [`onInAppMessage`](#oninappmessage)                     | property     | Stream of in-app message events        |
|                        | [`pauseInAppMessages`](#pauseinappmessages)             | method       | Holds messages back                    |
|                        | [`resumeInAppMessages`](#resumeinappmessages)           | method       | Lets messages show again               |
|                        | [`discardInAppMessages`](#discardinappmessages)         | method       | Drops the waiting message              |
|                        | [`setInAppExcludedScreens`](#setinappexcludedscreens)   | method       | Screens where no message shows         |
|                        | [`setInAppDebugLogging`](#setinappdebuglogging)         | method       | Logs why campaigns were skipped        |
| **Types**              | [`DeeplinkDetails`](#deeplinkdetails)                   | class        | A resolved deep link                   |
|                        | [`GenerateLinkParams`](#generatelinkparams)             | class        | Options for `generateLink`             |
|                        | [`GrovsLinkDetails`](#grovslinkdetails)                 | class        | Result of `linkDetails`                |
|                        | [`TrackingParams`](#trackingparams)                     | class        | UTM parameters                         |
|                        | [`CustomRedirects`](#customredirects)                   | class        | Per-platform link redirects            |
|                        | [`CustomLinkRedirect`](#customlinkredirect)             | class        | One platform redirect                  |
|                        | [`TransactionType`](#transactiontype)                   | enum         | Buy, cancel or refund                  |
|                        | [`InAppMessageEvent`](#inappmessageevent)               | sealed class | An event on `onInAppMessage`           |
|                        | [`InAppDismissReason`](#inappdismissreason)             | enum         | Why a message closed                   |
|                        | [`GrovsError`](#grovserror)                             | class        | An SDK error on `onError`              |
|                        | [`GrovsErrorCode`](#grovserrorcode)                     | enum         | SDK error categories                   |
|                        | [`GrovsException`](#grovsexception)                     | class        | A failed method call                   |
|                        | [Error codes](#error-codes)                             | type         | `GrovsException.code` values           |
|                        | [`GrovsNavigatorObserver`](#grovsnavigatorobserver)     | class        | Reports route changes                  |

---

## Setup

The native SDK is configured before Dart runs, so there's no "not configured" state. See [Quick Start](https://docs.grovs.io/docs/sdk/flutter/quick-start#configuration).

### Native configuration keys

Read once at launch by the native bridges.

| Info.plist                | AndroidManifest.xml `meta-data` | Type                                                       | Default     |
| ------------------------- | ------------------------------- | ---------------------------------------------------------- | ----------- |
| `GrovsApiKey`             | `grovs_api_key`                 | string                                                     | required    |
| `GrovsUseTestEnvironment` | `grovs_use_test_environment`    | boolean                                                    | `false`     |
| `GrovsBaseURL`            | `grovs_base_url`                | string                                                     | Grovs cloud |
| `GrovsClipboardDomains`   | `grovs_clipboard_domains`       | array of strings on iOS, comma-separated string on Android | none        |
| `GrovsEnabled`            | `grovs_enabled`                 | boolean                                                    | `true`      |

### setSDK

Kind: method · Since 3.0

```dart
Future<void> setSDK(bool enabled)
```

Turns collection on or off at runtime, for example when consent changes. See [Privacy & Consent](https://docs.grovs.io/docs/sdk/flutter/privacy).

- While disabled, the native SDK doesn't authenticate, read the clipboard, or send events, screen views or purchases. The plugin drops deep links.
- Enabling replays the link that launched the app while disabled.
- Setting the current state is a no-op.
- Not persisted. Set the initial state with `GrovsEnabled` / `grovs_enabled`.

### setDebugLevel

Kind: method

```dart
Future<void> setDebugLevel(String level)
```

Sets the native log level: `'info'` for everything, `'error'` for errors only.

- Case-insensitive. Any other value means `'error'`.

### onError

Kind: property · Since 3.0

```dart
Stream<GrovsError> get onError
```

Broadcast stream of asynchronous native SDK errors, as [`GrovsError`](#grovserror). See [Handling SDK errors](https://docs.grovs.io/docs/sdk/flutter/deep-linking#handling-sdk-errors).

- iOS only. On Android it never emits.
- iOS buffers the 20 most recent errors before the first listener.
- Unknown error codes are dropped.
- In-app display failures arrive on [`onInAppMessage`](#oninappmessage) as `InAppMessageFailed`, not here.

### getPlatformVersion

Kind: method

```dart
Future<String?> getPlatformVersion()
```

Gets the host OS version, such as `"iOS 17.4"` or `"Android 14"`. Useful to smoke-test plugin registration.

- The only method that lets the raw `PlatformException` through instead of `GrovsException`.

---

## Deep links

### onDeeplinkReceived

Kind: property

```dart
Stream<DeeplinkDetails> get onDeeplinkReceived
```

Broadcast stream of [`DeeplinkDetails`](#deeplinkdetails) for every resolved link, including deferred links matched after install, links passed to [`handleUrl`](#handleurl) and taps on Grovs pushes. See [Deep Linking](https://docs.grovs.io/docs/sdk/flutter/deep-linking).

- Up to 20 events before the first listener are buffered and replayed to it.
- Nothing is emitted while disabled.
- For a push without a link, `link` is `null`. See [What your app receives](https://docs.grovs.io/docs/sdk/flutter/push-notifications#what-your-app-receives).

### handleUrl

Kind: method · Since 3.1

```dart
Future<bool> handleUrl(String url)
```

Resolves a Grovs link tapped inside your app. The system doesn't hand a universal link or App Link back to the app that opened it. The result arrives on [`onDeeplinkReceived`](#ondeeplinkreceived). See [Links tapped inside your app](https://docs.grovs.io/docs/sdk/flutter/deep-linking#links-tapped-inside-your-app).

**Returns** `true` when the link was handed to the native SDK.

- `url` must be absolute, with a scheme and a host. Otherwise throws `INVALID_ARGUMENT`.
- Returns `false` without queuing the link while the SDK is disabled, and on Android when no activity is attached.

---

## Users

### setUserIdentifier

Kind: method

```dart
Future<void> setUserIdentifier(String identifier)
```

Sets your identifier for the current user, typically your `user_id`. Shown in the dashboard and reports.

- Held while the SDK is disabled.

### setUserAttributes

Kind: method

```dart
Future<void> setUserAttributes(Map<String, dynamic> attributes)
```

Sets attributes of the current user, shown in the dashboard.

- Values must be platform-channel encodable: null, booleans, numbers, strings, lists, or maps with string keys.
- Held while the SDK is disabled.

---

## Links

### generateLink

Kind: method

```dart
Future<String> generateLink(GenerateLinkParams params)
```

Creates a smart link. Fields: [`GenerateLinkParams`](#generatelinkparams). See [Link Creation](https://docs.grovs.io/docs/sdk/flutter/link-creation).

**Returns** the URL. Completes when the native operation finishes.

- Throws `GrovsException` with `GENERATION_ERROR` when generation fails, including while disabled or unauthenticated.

### linkDetails

Kind: method · Since 3.1.1

```dart
Future<GrovsLinkDetails> linkDetails(String path)
```

Gets the details of a link by its path, the last part of the link (`abc123` for `https://yourapp.sqd.link/abc123`). Pass the path only, not the full URL. See [Link details](https://docs.grovs.io/docs/sdk/flutter/link-creation#link-details).

**Returns** a [`GrovsLinkDetails`](#grovslinkdetails).

- Throws `INVALID_ARGUMENT` when `path` is empty or whitespace, `SDK_DISABLED` while the SDK is disabled, and `LINK_DETAILS_ERROR` when the link isn't found or the request fails.

---

## Events

See [Events & Screen Tracking](https://docs.grovs.io/docs/sdk/flutter/analytics).

### track

Kind: method · Since 3.0

```dart
Future<void> track(
  String name, {
  Map<String, dynamic>? properties,
  List<String>? tags,
})
```

Tracks a custom event.

- The name can't be empty or a reserved system name.
- Rules and limits: [Tracking custom events](https://docs.grovs.io/docs/sdk/flutter/analytics#tracking-custom-events).

### trackScreenView

Kind: method · Since 3.0

```dart
Future<void> trackScreenView(
  String screenName, {
  Map<String, dynamic>? properties,
})
```

Tracks a screen view manually.

- The native SDK drops a repeat of the same screen within one second.

### navigatorObserver

Kind: property · Since 3.0

```dart
static GrovsNavigatorObserver get navigatorObserver
```

A shared [`GrovsNavigatorObserver`](#grovsnavigatorobserver) for automatic screen tracking. See [Automatic screen tracking](https://docs.grovs.io/docs/sdk/flutter/analytics#automatic-screen-tracking).

```dart
MaterialApp(
  navigatorObservers: [Grovs.navigatorObserver],
)
```

### setGlobalTags

Kind: method · Since 3.0

```dart
Future<void> setGlobalTags(List<String>? tags)
```

Sets tags merged onto every later event. Pass `null` to clear them.

### setScreenAliases

Kind: method · Since 3.0

```dart
Future<void> setScreenAliases(Map<String, String> aliases)
```

Maps raw screen names to dashboard names. See [Screen name aliases](https://docs.grovs.io/docs/sdk/flutter/analytics#screen-name-aliases).

- Stored in Dart for `GrovsNavigatorObserver` and forwarded to the native SDK, which syncs it.

### screenAliases

Kind: property

```dart
static Map<String, String> get screenAliases
```

Unmodifiable view of the aliases last passed to `setScreenAliases`. `GrovsNavigatorObserver` applies them to automatic screen views.

---

## Revenue

See [Revenue](https://docs.grovs.io/docs/sdk/flutter/revenue).

### logInAppPurchase

Kind: method

```dart
Future<void> logInAppPurchase(String transactionId)
```

Logs a platform store purchase. Completes when the native operation finishes.

| Platform | Pass                                               |
| -------- | -------------------------------------------------- |
| iOS      | The StoreKit 2 transaction ID as a decimal string. |
| Android  | The Play Billing purchase's `originalJson`.        |

- On iOS, a value that isn't an unsigned 64-bit integer throws `INVALID_ARGUMENT`.
- A purchase the native SDK couldn't log throws `PAYMENT_ERROR`.

### logCustomPurchase

Kind: method

```dart
Future<void> logCustomPurchase({
  required TransactionType type,
  required int priceInCents,
  required String currency,
  required String productId,
  DateTime? startDate,
})
```

Logs a purchase, cancellation or refund made outside the platform store. Completes when the native operation finishes.

| Name           | Type              | Description                                                                |
| -------------- | ----------------- | -------------------------------------------------------------------------- |
| `type`         | `TransactionType` | [`buy`, `cancel` or `refund`](#transactiontype).                           |
| `priceInCents` | `int`             | Price in cents.                                                            |
| `currency`     | `String`          | ISO 4217 code.                                                             |
| `productId`    | `String`          | Your product identifier.                                                   |
| `startDate`    | `DateTime?`       | Sent as epoch milliseconds and honored on both platforms. Defaults to now. |

---

## Push notifications

### setPushToken

Kind: method

```dart
Future<void> setPushToken(String token)
```

Sets the push token for push campaigns: the APNs device token on iOS, the FCM registration token on Android. See [Push notifications](https://docs.grovs.io/docs/sdk/flutter/push-notifications).

- iOS: not needed. The plugin passes the APNs token once the app registers for remote notifications. Calling it still works, with one extra attributes update.
- Android: the plugin fetches the first FCM token when Firebase is present, and again on `setSDK(true)`. Pass refreshes from `onTokenRefresh`.
- Held while the SDK is disabled.

### isGrovsNotification

Kind: method · Since 3.1.1

```dart
Future<bool> isGrovsNotification(Map<String, dynamic> data)
```

Checks whether Grovs sent a push, without handling it. Pass the push's data, for example `RemoteMessage.data` from `firebase_messaging`.

**Returns** `true` when the data has a non-empty `grovs_campaign_id`.

### handleNotificationOpen

Kind: method · Since 3.1.1

```dart
Future<bool> handleNotificationOpen(Map<String, dynamic> data)
```

Counts a tap on a Grovs push and opens its link. The push is delivered on [`onDeeplinkReceived`](#ondeeplinkreceived). See [Handling taps yourself](https://docs.grovs.io/docs/sdk/flutter/push-notifications#handling-taps-yourself).

**Returns** `true` when the data belongs to a Grovs push and the tap was handled. `false` for other pushes and while the SDK is disabled.

- Call it only from a tap handler, never when a push is delivered.
- Only when the native path isn't wired. On iOS, setting the notification center delegate and also calling this counts each tap twice.
- On Android, values in `data` are passed as strings.

---

## In-app messages

See [In-app messages](https://docs.grovs.io/docs/sdk/flutter/in-app-messages).

### onInAppMessage

Kind: property · Since 3.1.1

```dart
Stream<InAppMessageEvent> get onInAppMessage
```

Broadcast stream of [`InAppMessageEvent`](#inappmessageevent): shown, clicked, dismissed, answered and failed.

- Up to 20 events before the first listener are buffered and replayed to it.
- On Android, events sent while no Flutter engine is attached are dropped. On iOS they're kept for the next engine.
- Nothing is emitted while disabled.
- Events with an unknown type or a missing required field are dropped.

### pauseInAppMessages

Kind: method · Since 3.1.1

```dart
Future<void> pauseInAppMessages()
```

Holds in-app messages back until [`resumeInAppMessages`](#resumeinappmessages). The newest highest priority one waits.

### resumeInAppMessages

Kind: method · Since 3.1.1

```dart
Future<void> resumeInAppMessages()
```

Lets messages show again after `pauseInAppMessages` or `discardInAppMessages`, starting with the one that waited, if it still qualifies.

### discardInAppMessages

Kind: method · Since 3.1.1

```dart
Future<void> discardInAppMessages({bool dismissCurrent = false})
```

Drops the waiting message and stays paused. Call `resumeInAppMessages` to show new ones. With `dismissCurrent: true`, also closes the message on screen.

### setInAppExcludedScreens

Kind: method · Since 3.1.1

```dart
Future<void> setInAppExcludedScreens(List<String> screens)
```

Sets screens where no message shows. Messages wait until the user leaves.

- Matched against the names sent by `trackScreenView` and `GrovsNavigatorObserver`, after screen aliases are applied.
- Case is ignored.

### setInAppDebugLogging

Kind: method · Since 3.1.1

```dart
Future<void> setInAppDebugLogging(bool enabled)
```

Logs each campaign considered for an event and why it was skipped.

- On iOS, also call `setDebugLevel('info')` to see the logs.
- On Android, logs go to Logcat under the tag `GrovsInApp`, whatever the debug level.

---

## Types

### DeeplinkDetails

Kind: class

```dart
class DeeplinkDetails {
  final String? link;
  final Map<String, dynamic>? data;
  final TrackingParams? tracking;
}
```

A resolved deep link, emitted on [`onDeeplinkReceived`](#ondeeplinkreceived).

| Name       | Type                    | Description                                              |
| ---------- | ----------------------- | -------------------------------------------------------- |
| `link`     | `String?`               | The link that opened the app, or `null` if unavailable.  |
| `data`     | `Map<String, dynamic>?` | The custom payload attached to the link.                 |
| `tracking` | `TrackingParams?`       | UTM campaign, source and medium for the link, or `null`. |

- `toMap()` returns the same fields as a map, with `tracking` expanded to its three `utm_` keys.

### GenerateLinkParams

Kind: class

```dart
class GenerateLinkParams {
  GenerateLinkParams({
    required String title,
    String? subtitle,
    String? imageURL,
    Map<String, dynamic>? data,
    List<String>? tags,
    CustomRedirects? customRedirects,
    bool? showPreviewIos,
    bool? showPreviewAndroid,
    bool? copyToClipboardIos,
    bool? copyToClipboardAndroid,
    TrackingParams? tracking,
  });
}
```

Options for [`generateLink`](#generatelink). See [Link Creation](https://docs.grovs.io/docs/sdk/flutter/link-creation#parameters).

| Name                     | Type                    | Description                                                                                                                                                                                                           |
| ------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `title`                  | `String`                | Link preview title. Required.                                                                                                                                                                                         |
| `subtitle`               | `String?`               | Link preview subtitle.                                                                                                                                                                                                |
| `imageURL`               | `String?`               | Link preview image URL.                                                                                                                                                                                               |
| `data`                   | `Map<String, dynamic>?` | Custom payload delivered on deep link open.                                                                                                                                                                           |
| `tags`                   | `List<String>?`         | Tags for filtering and analytics.                                                                                                                                                                                     |
| `customRedirects`        | `CustomRedirects?`      | Per-platform [redirect overrides](#customredirects).                                                                                                                                                                  |
| `showPreviewIos`         | `bool?`                 | Show the preview page on iOS. `null` uses the project default.                                                                                                                                                        |
| `showPreviewAndroid`     | `bool?`                 | Show the preview page on Android. `null` uses the project default.                                                                                                                                                    |
| `copyToClipboardIos`     | `bool?`                 | Copy the link on the iOS preview page, for [clipboard-assisted deferred deep linking](https://docs.grovs.io/docs/sdk/flutter/deep-linking#clipboard-assisted-deferred-deep-linking). `null` uses the project setting. |
| `copyToClipboardAndroid` | `bool?`                 | Same, for Android.                                                                                                                                                                                                    |
| `tracking`               | `TrackingParams?`       | [UTM campaign, source and medium](#trackingparams).                                                                                                                                                                   |

### GrovsLinkDetails

Kind: class · Since 3.1.1

```dart
class GrovsLinkDetails {
  final int? id;
  final String? name;
  final String? path;
  final String? title;
  final String? subtitle;
  final String? image;
  final String? accessPath;
  final bool? active;
  final bool? sdkGenerated;
  final Map<String, dynamic>? data;
  final List<String>? tags;
  final DateTime? updatedAt;
  final bool? showPreviewIos;
  final bool? showPreviewAndroid;
  final String? generatedFromPlatform;
  final String? adsPlatform;
  final int? campaignId;
  final TrackingParams? tracking;
  final CustomRedirects? customRedirects;
  final Map<String, dynamic> raw;
}
```

The result of [`linkDetails`](#linkdetails).

| Name              | Description                                                                                                                     |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `path`            | The last part of the link, for example `abc123`.                                                                                |
| `image`           | URL of the link's preview image.                                                                                                |
| `accessPath`      | The full link URL.                                                                                                              |
| `data`            | The payload attached to the link, as received.                                                                                  |
| `tracking`        | UTM campaign, source and medium, or `null` when none is set.                                                                    |
| `customRedirects` | Per-platform redirects, or `null` when none is set. A redirect without `open_app_if_installed` gets `openAppIfInstalled: true`. |
| `raw`             | Every field the backend sent, as received. Numbers can be doubles on Android and ints on iOS.                                   |

- A field whose value has an unexpected type is `null`. Typed fields are the same on both platforms.

### TrackingParams

Kind: class

```dart
class TrackingParams {
  TrackingParams({String? utmCampaign, String? utmSource, String? utmMedium});
}
```

UTM parameters for link generation, and a received link's tracking metadata.

### CustomRedirects

Kind: class

```dart
class CustomRedirects {
  CustomRedirects({
    CustomLinkRedirect? ios,
    CustomLinkRedirect? android,
    CustomLinkRedirect? desktop,
  });
}
```

Per-platform redirect overrides for [`generateLink`](#generatelink).

### CustomLinkRedirect

Kind: class

```dart
class CustomLinkRedirect {
  CustomLinkRedirect({required String url, bool openAppIfInstalled = true});
}
```

One platform redirect. When `openAppIfInstalled` is `true`, the app opens if installed. Otherwise `url` is always used.

### TransactionType

Kind: enum

```dart
enum TransactionType { buy, cancel, refund }
```

Used with [`logCustomPurchase`](#logcustompurchase).

### InAppMessageEvent

Kind: class · Since 3.1.1

```dart
sealed class InAppMessageEvent {
  String? get campaignId;
}

final class InAppMessageShown extends InAppMessageEvent {
  final String campaignId;
}

final class InAppMessageClicked extends InAppMessageEvent {
  final String campaignId;
  final String? buttonId;
  final Map<String, dynamic>? payload;
}

final class InAppMessageDismissed extends InAppMessageEvent {
  final String campaignId;
  final InAppDismissReason reason;
}

final class InAppMessageAnswered extends InAppMessageEvent {
  final String campaignId;
  final Object value;
  final String? comment;
}

final class InAppMessageFailed extends InAppMessageEvent {
  final String? campaignId;
  final String message;
}
```

An event on [`onInAppMessage`](#oninappmessage). Exported from `grovs.dart`. See [React to messages](https://docs.grovs.io/docs/sdk/flutter/in-app-messages#react-to-messages).

| Class                   | Sent when                                                                                                                                |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `InAppMessageShown`     | The message is on screen and counted as viewed.                                                                                          |
| `InAppMessageClicked`   | A button or the message was tapped. `buttonId` is `null` for the message. `payload` carries a key-value action's pairs.                  |
| `InAppMessageDismissed` | The message closed without a click.                                                                                                      |
| `InAppMessageAnswered`  | A question was answered and the message closed, in place of the dismissal. `value` is the star rating (`int`) or the chosen option's ID. |
| `InAppMessageFailed`    | The message couldn't be drawn. `campaignId` is `null` on iOS.                                                                            |

### InAppDismissReason

Kind: enum · Since 3.1.1

```dart
enum InAppDismissReason { closeButton, backdrop, swipe, app, orientation, unknown }
```

Why a message closed, on [`InAppMessageDismissed`](#inappmessageevent).

| Value         | Native value   | Meaning                                                         |
| ------------- | -------------- | --------------------------------------------------------------- |
| `closeButton` | `close_button` | The close button.                                               |
| `backdrop`    | `backdrop`     | A tap outside the message.                                      |
| `swipe`       | `swipe`        | Swiped away.                                                    |
| `app`         | `app`          | Closed by the SDK or your app.                                  |
| `orientation` | `orientation`  | The device turned to an orientation the campaign doesn't allow. |
| `unknown`     | anything else  | A value this plugin version doesn't know.                       |

### GrovsError

Kind: class · Since 3.0

```dart
class GrovsError {
  final GrovsErrorCode code;
  final String message;
}
```

An SDK error, emitted on [`onError`](#onerror).

### GrovsErrorCode

Kind: enum · Since 3.0

```dart
enum GrovsErrorCode {
  authenticationFailed,   // 'authentication_failed'
  networkRequestFailed,   // 'network_request_failed'
  eventDispatchFailed,    // 'event_dispatch_failed'
  linkGenerationFailed,   // 'link_generation_failed'
}
```

The category of a [`GrovsError`](#grovserror).

- `nativeName` is the native snake-case name.
- `GrovsErrorCode.fromNativeName` maps a name back to a value, or `null` if unknown.

### GrovsException

Kind: class

```dart
class GrovsException implements Exception {
  final String message;
  final String? code;
}
```

Thrown when a native call fails. Every method except `getPlatformVersion` uses it.

- `code` is one of the [error codes](#error-codes), or `null` for a Dart-side failure.

### Error codes

`GrovsException.code` values raised by the native bridges:

| Code                 | Platform | Raised when                                                                                                                                                                                                                                    |
| -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `INVALID_ARGUMENT`   | both     | A required argument is missing, `TransactionType` is unknown, the `handleUrl` URL has no scheme or host, the `linkDetails` path is empty (checked in Dart), or on iOS the `logInAppPurchase` transaction ID is not an unsigned 64-bit integer. |
| `GENERATION_ERROR`   | both     | `generateLink` failed.                                                                                                                                                                                                                         |
| `SDK_DISABLED`       | both     | `linkDetails` was called while the SDK is disabled.                                                                                                                                                                                            |
| `LINK_DETAILS_ERROR` | both     | `linkDetails` found no link or the request failed.                                                                                                                                                                                             |
| `PAYMENT_ERROR`      | both     | `logInAppPurchase` or `logCustomPurchase` failed: the native completion reported failure on iOS, or the native call threw on Android.                                                                                                          |
| `TOKEN_ERROR`        | Android  | `setPushToken` threw natively.                                                                                                                                                                                                                 |
| `USER_ERROR`         | Android  | `setUserIdentifier` or `setUserAttributes` threw natively.                                                                                                                                                                                     |
| `DEBUG_ERROR`        | Android  | `setDebugLevel` threw natively.                                                                                                                                                                                                                |
| `EVENT_ERROR`        | Android  | An event method (`track`, `trackScreenView`, `setGlobalTags` or `setScreenAliases`) threw natively.                                                                                                                                            |
| `CONSENT_ERROR`      | Android  | `setSDK` threw natively.                                                                                                                                                                                                                       |

- On iOS the user, event and consent setters are fire-and-forget and never throw.

### GrovsNavigatorObserver

Kind: class · Since 3.0

```dart
class GrovsNavigatorObserver extends NavigatorObserver {
  GrovsNavigatorObserver({
    String? Function(Route<dynamic> route)? screenNameExtractor,
    Grovs? grovs,
  });
}
```

Reports a screen view for each route change. Use the shared [`Grovs.navigatorObserver`](#navigatorobserver), or construct one to customize names. See [Automatic screen tracking](https://docs.grovs.io/docs/sdk/flutter/analytics#automatic-screen-tracking).

| Navigator event | Route reported     |
| --------------- | ------------------ |
| `didPush`       | The pushed route   |
| `didReplace`    | The new route      |
| `didPop`        | The route revealed |

- Only `PageRoute`s are reported.
- The name comes from `screenNameExtractor`, then `RouteSettings.name`, then the runtime type. It's translated through `Grovs.screenAliases`.
