LogoLogo
SentianceInsights-Control-TowerLegacy DocsImportant Security Notice
  • Introduction
  • Integrating the SDK
    • Getting Started
    • Android Quick Start
      • 1. Including the SDK
      • 2. Initialization
      • 3. User Creation
      • 4. Enabling Detections
      • 5. SDK Status Updates
      • 6. Permissions
      • 7. Additional Requirements
    • iOS Quick Start
      • 1. Including the SDK
        • Using CocoaPods
        • Using Carthage
        • Using Swift Package Manager
        • Manual Integration
      • 2. Project Settings
      • 3. Initialization
      • 4. User Creation
      • 5. Enabling Detections
      • 6. SDK Status Updates
      • 7. Permissions
      • 8. Additional Requirements
    • React Native Quick Start
      • 1. Including the SDK
      • 2. Configuration
      • 3. Initialization
      • 4. User Creation
      • 5. Enabling Detections
      • 6. SDK Status Updates
    • Flutter Quick Start
      • 1. Including the SDK
      • 2. Configuration
      • 3. Initialization
      • 4. User Creation
      • 5. Enabling Detections
      • 6. SDK Status Updates
    • What Comes After Integration
    • Integration (FAQ)
    • Detections (FAQ)
  • Sentiance Insights
    • Overview of Sentiance Insights
      • Driving Insights
        • Transports
        • Driving Events and Scores
        • Car Crashes
      • Mobility and Lifestyle Insights
        • Visit Essentials
        • User Segmentation
    • Engagement
      • User Adaptive Score
      • Streaks
      • Challenges
      • Reward System
      • Communication Campaign
      • Social Groups
        • Technical Details
    • Accessing Sentiance Insights
      • via On Device API
      • via Cloud API
      • via Firehose - Realtime Messages
      • via Offloads
  • FAQ
    • Security, Privacy and Terms of Service (FAQ)
  • Important topics
    • SDK
      • Appendix
        • Android
          • Android 10 Update Behavior
          • Android Battery Optimization
          • Artifacts & Dependencies
          • Manifest Permissions
          • Notification Management
          • Sample Notification
          • Supported API Levels
        • iOS
          • App Store Privacy Section
          • App Store Release
          • Apple Privacy Manifest
          • ARM Simulator Support
          • Dependencies
          • iOS 13 permission changes
          • Supported iOS Versions & Architectures
          • Swift Support
          • v5.x Framework Files
          • v6.x Framework Files
        • Controlled Detections
          • Automatic Detections
          • Automatic Detections with Forced Trips
          • Controlled Trips Only
          • Checking Trip Status
        • Control Sending Data
        • Custom User Metadata
        • Detecting Vehicle Crashes
        • Feature Production Readiness
        • Migration Guide
          • Android
          • iOS
          • React Native
          • Flutter
        • On-Device Features
        • React Native
        • SDK Initialization
        • User Access Token
        • User Creation
        • User Linking
        • Xamarin
      • API Reference
        • Android
          • AsyncInitializationError
          • AsyncInitializationResult
          • DateTime
          • DetectionStatus
          • DisableDetectionsError
          • DisableDetectionsResult
          • Driving Insights
            • CallWhileMovingEvent
            • DrivingInsight
            • DrivingInsightsApi
            • DrivingInsightsReadyListener
            • HarshDrivingEvent
              • Type
            • PhoneUsageEvent
            • SafetyScores
            • SafetyScoreRequestParameters
              • Builder
              • OccupantRoles
              • Period
              • TransportModes
            • SpeedingEvent
          • Smart Geofences
            • DetectionMode
            • SmartGeofence
            • SmartGeofenceApi
            • SmartGeofenceEvent
              • Type
            • SmartGeofenceEventListener
            • SmartGeofencesRefreshError
              • SmartGeofencesRefreshFailureReason
            • SmartGeofencesRefreshResult
          • EnableDetectionsError
            • EnableDetectionsFailureReason
          • EnableDetectionsResult
          • EventTimeline
            • EventType
            • TransportMode
            • Event
              • OffTheGridEvent
              • StationaryEvent
              • TransportEvent
              • UnknownEvent
            • EventTimelineUpdateListener
            • EventTimelineApi
            • OccupantRole
            • Venue
              • VenueType
              • VenueSignificance
          • Feedback
            • FeedbackApi
            • OccupantRoleFeedback
            • OccupantRoleFeedbackResult
          • GeoLocation
          • InitializationResult
            • InitializationFailureReason
          • InitState
          • MetaUserLinker
          • MetaUserLinkerAsync
          • MetaUserLinkerCallback
          • OnInitCallback
            • InitIssue
          • OnSdkStatusUpdateHandler
          • OnStartFinishedHandler
          • PendingOperation
            • OnSuccessListener
            • OnFailureListener
            • OnFailureListener
            • OnCompleteListener
          • ResetCallback
            • ResetCallback.ResetFailureReason
          • ResetError
            • ResetFailureReason
          • ResetResult
          • SdkConfig
            • LocationPermission
            • Builder
          • SdkException
          • SdkStatus
            • LocationSetting
            • Quota Status
            • StartStatus
          • SdkStatusUpdateListener
          • Sentiance
          • SentianceOptions
            • SentianceOptions.Builder
          • StartTripError
            • StartTripFailureReason
          • StartTripResult
          • StationaryInfo
          • StopTripError
            • StopTripFailureReason
          • StopTripResult
          • SubmitDetectionsCallback
          • SubmitDetectionsError
            • SubmitDetectionsFailureReason
          • SubmitDetectionsResult
          • Token
          • TokenResultCallback
          • TransmittableDataType
          • Transport Sessions
            • SensorDataChunk
            • TransportSession
            • TransportSessionApi
            • TransportSessionListener
          • Trip
            • StartTripCallback
            • StopTripCallback
            • TransportMode
            • TripTimeoutListener
            • TripType
          • TripInfo
          • UserAccessTokenError
            • UserAccessTokenFailureReason
          • UserActivity
          • UserActivityListener
          • UserActivityType
          • UserContext
            • Attribute
            • Segment
              • SegmentCategory
              • SegmentSubcategory
              • SegmentType
            • SemanticTime
          • UserContextApi
            • RequestUserContextFailureReason
            • RequestUserContextError
            • UserContextUpdateCriteria
            • UserContextUpdateListener
          • UserCreationError
            • UserCreationFailureReason
          • UserCreationOptions
            • UserCreationOptions.Builder
          • UserCreationResult
            • UserInfo
          • UserLinker
          • UserLinkerAsync
          • UserLinkerCallback
          • UserLinkingError
            • UserLinkingFailureReason
          • UserLinkingResult
          • VehicleCrashDetection
            • CrashDetectionApi
            • CrashDetectionState
            • VehicleCrashDiagnostic
            • VehicleCrashEvent
            • VehicleCrashDiagnosticListener
            • VehicleCrashListener
            • VehicleCrashSeverity
          • Waypoint
        • iOS
          • Detections
            • Enable Detections
            • Disable Detections
          • Driving Insights
            • SENTCallWhileMovingEvent
            • SENTDrivingInsights
            • SENTDrivingInsightsReadyDelegate
            • SENTHarshDrivingEvent
              • HarshDrivingEventType
            • SENTPhoneUsageEvent
            • SENTSpeedingEvent
            • SENTSafetyScores
            • SafetyScoreRequestParameters
              • SafetyScoreRequestOccupantRoleOption
              • SafetyScoreRequestPeriod
              • SafetyScoreRequestTransportModeOption
          • Event Timeline
            • EventTimelineDelegate
            • SENTOccupantRole
            • SENTTimelineEvent
              • SENTOffTheGridEvent
              • SENTStationaryEvent
              • SENTTransportEvent
              • SENTUnknownEvent
            • SENTTimelineEventType
            • SENTTimelineTransportMode
            • SENTVenue
            • SENTVenueSignificance
            • SENTVenueType
          • Feedback
            • SENTFeedback
            • SENTOccupantRoleFeedback
            • SENTOccupantRoleFeedbackResult
          • SENTCompletionHandlers
          • SENTConfig
          • SENTDate
          • SENTGeolocation
          • SENTAsyncInitializationCompletionHandler
          • SENTAsyncInitializationError
          • SENTAsyncInitializationResult
          • Sentiance
          • SENTInitializationResult
          • SENTOptions
            • SENTOptionsInitPurpose
          • SENTPublicDefinitions
          • SENTSDKStatus
          • SENTToken
          • SENTTransmittableDataType
          • SENTUserActivity
          • SENTVehicleCrashDetectionState
          • SENTVehicleCrashDiagnostic
          • SENTVehicleCrashEvent
            • SENTVehicleCrashSeverity
          • SENTWaypoint
          • Smart Geofences
            • SENTSmartGeofencesRefreshHandler
            • SmartGeofenceDetectionMode
            • SmartGeofencesRefreshError
              • SmartGeofencesRefreshFailureReason
            • SmartGeofencesRefreshResult
            • SmartGeofence
            • SmartGeofenceEvent
              • SmartGeofenceEventType
            • SmartGeofenceEventDelegate
          • Transport Sessions
            • SENTAccelerometerDataIterator
            • SENTLocationDataIterator
            • SENTSensorDataChunk
            • SENTTransportSession
          • User Context
            • SENTAttribute
            • SENTRequestUserContextCompletionHandler
            • SENTRequestUserContextError
            • SENTRequestUserContextFailureReason
            • SENTSegment
              • SENTSegmentCategory
              • SENTSegmentSubCategory
              • SENTSegmentType
            • SENTSemanticTime
            • SENTUserContext
            • SENTUserContextDelegate
            • SENTUserContextUpdateCriteria
          • User Creation & Linking
            • SENTUserInfo
            • User Creation
              • SENTUserCreationResult
              • SENTUserCreationFailureReason
              • SENTUserCreationError
              • SENTUserCreationCompletionHandler
              • SENTUserCreationOptions
            • User Linking
              • SENTNoOpUserLinker
              • SENTUserLinkingResult
              • SENTUserLinkingFailureReason
              • SENTUserLinkingError
              • SENTUserLinkingCompletionHandler
              • SENTUserLinker
        • React Native
          • core
            • Definitions
            • Examples
          • crash-detection
            • Definitions
            • Examples
          • driving-insights
            • Definitions
            • Examples
          • smart-geofences
            • Definitions
            • Examples
          • event-timeline
            • Definitions
            • Examples
          • legacy
            • Definitions
            • Examples
          • user-context
            • Definitions
            • Examples
        • Flutter
      • Battery Optimization on Android
      • How To
        • Check the Location Permissions
        • Utilize the Event Timeline API
        • Utilize the Driving Insights API
        • Utilize the User Context API
        • Utilize the Smart Geofences API
      • Troubleshooting
        • Android
        • iOS
      • Changelog
        • Android
        • iOS
        • React Native
        • Flutter
    • Authentication and Authorization
    • User Creation (via Authentication Code)
    • User Deletion
    • PlayStore Location Access Review
    • Privacy Report & Dashboard
    • Crash Detection
    • Important Security Notice
    • Injecting Fake Data
    • Custom Aggregation For Analytics
    • Merging Scores for Motorcycles and Cars
  • Links
    • SDK Standard License
    • Insights-by-Sentiance Application
    • Insights-by-Sentiance Privacy Policy
    • Journeys License
    • Technical & Organizational Measures
Powered by GitBook
On this page
  1. Important topics
  2. SDK
  3. API Reference
  4. React Native
  5. smart-geofences

Definitions

declare module "@sentiance-react-native/smart-geofences" {
  import { EmitterSubscription } from "react-native";
  import { SdkStatus } from "@sentiance-react-native/core";

  export type SmartGeofenceEventType = "ENTRY" | "EXIT";

  export interface SmartGeofencesRefreshFailureReason {
    /**
     * The feature is not enabled for your app.
     */
    FEATURE_NOT_ENABLED: "FEATURE_NOT_ENABLED";
    /**
     * Failed to refresh the monitored geofences due to network usage being restricted.
     * In most cases, this means the device is connected to a mobile data network, but you have disabled
     * mobile data network usage using the {@link SentianceCore.setIsAllowedToUseMobileData core module's mobile usage API}.
     */
    NETWORK_USAGE_RESTRICTED: "NETWORK_USAGE_RESTRICTED";
    /**
     * A network error was encountered when attempting to refresh the monitored geofences.
     */
    NETWORK_ERROR: "NETWORK_ERROR";
    /**
     * A server error was encountered when attempting to refresh the monitored geofences.
     */
    SERVER_ERROR: "SERVER_ERROR";
    /**
     * The application tried to refresh the list of monitored geofences more than once within
     * the last 30 seconds.
     */
    TOO_MANY_FREQUENT_CALLS: "TOO_MANY_FREQUENT_CALLS";
    /**
     * An unexpected error occurred. Check the corresponding {@link SmartGeofencesRefreshError#details} for more info.
     */
    UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
    /**
     * No Sentiance user is present on device. Call {@link SentianceCore.createUser} to create a user.
     */
    NO_USER: "NO_USER";
    /**
     * The user is disabled remotely.
     */
    USER_DISABLED_REMOTELY: "USER_DISABLED_REMOTELY";
  }

  export enum DetectionMode {
    /**
     * The Smart Geofences feature is not enabled for your app.
     */
    FEATURE_NOT_ENABLED = "FEATURE_NOT_ENABLED",
    /**
     * Geofence entry/exit detections are disabled. Check the {@link SdkStatus } to find out why.
     */
    DISABLED = "DISABLED",
    /**
     * Geofence entry/exit detections are limited to when the app is visible in the foreground,
     * due to restricted location permission.
     */
    FOREGROUND = "FOREGROUND",
    /**
     * Geofence entry/exit detections are running unrestricted in the background.
     */
    BACKGROUND = "BACKGROUND"
  }

  export interface Location {
    timestamp: number;
    latitude: number;
    longitude: number;
    accuracy?: number;
    altitude?: number;
    provider?: string; // Android only
  }

  export interface SmartGeofence {
    sentianceId: string;
    latitude: number;
    longitude: number;
    radius: number;
    externalId: string;
  }

  export interface SmartGeofenceEvent {
    timestamp: number;
    triggeringLocation: Location;
    eventType: SmartGeofenceEventType;
    geofences: SmartGeofence[];
  }

  export interface SmartGeofencesRefreshError {
    reason: SmartGeofencesRefreshFailureReason;
    details?: string;
  }

  export interface SentianceSmartGeofences {
    /**
     * Refreshes the list of geofences.
     *
     * @returns A Promise that resolves if the refresh was successful.
     *          The Promise does not return any value upon resolution.
     *
     * @throws {SmartGeofencesRefreshError} If the refresh fails, the Promise
     *         is rejected with an object of type `SmartGeofencesRefreshError`.
     *         This object contains a `reason` property detailing the nature of the error.
     *
     * @example
     * try {
     *     await refreshGeofences();
     *     console.log("Geofences refreshed successfully.");
     * } catch (error) {
     *     const refreshError = error.userInfo as SmartGeofencesRefreshError;
     *     console.error("Error refreshing geofences:", refreshError.reason);
     * }
     */
    refreshGeofences(): Promise<void>;

    /**
     * Registers a listener for smart geofence events.
     *
     * This function sets up an event listener that will execute the provided callback
     * function whenever a smart geofence event occurs (could be an entry, or an exit event).
     *
     * @param {Function} onSmartGeofenceEvent - A callback function that is called whenever
     *        a smart geofence event is triggered. The function receives a single argument:
     *        a `SmartGeofenceEvent` object containing details about the event.
     *
     * @returns {Promise<EmitterSubscription>} A Promise that resolves to an EmitterSubscription.
     *          This subscription object can be used to unsubscribe from the event notifications
     *          in the future, by calling `remove()` on the returned subscription object.
     *
     * @example
     * const subscription = await addSmartGeofenceEventListener(event => {
     *   console.log('Geofence event received:', event);
     * });
     * console.log('Listener registered, subscription:', subscription);
     */
    addSmartGeofenceEventListener(onSmartGeofenceEvent: (smartGeofenceEvent: SmartGeofenceEvent) => void): Promise<EmitterSubscription>;

    /**
     * Retrieves the geofence entry/exit detection mode.
     *
     * @example
     * const detectionMode = await getDetectionMode();
     * console.log('Detection mode is currently:', detectionMode);
     */
    getDetectionMode(): Promise<DetectionMode>;
  }

  const SentianceSmartGeofences: SentianceSmartGeofences;
  export default SentianceSmartGeofences;
}
Previoussmart-geofencesNextExamples

Last updated 10 months ago