Skip to content

Location Component ​

The LocationComponent synchronizes the webview's location and provides access to native iOS geo-location services.

Basic Info ​

Description ​

This component is used to manage location-based features, such as "Store Locator" or "Find Me," by bridging the CLLocationManager results to the webview. It also ensures the native app is aware of the current web URL for navigation tracking.

How to Use ​

1. Web Implementation ​

javascript
import { useLocation } from '@bagisto-native/react';

const NearMe = () => {
    const { getCurrentPosition } = useLocation();

    const findStores = () => {
        getCurrentPosition((pos) => {
            console.log("Lat:", pos.latitude, "Lng:", pos.longitude);
        });
    };

    return <button onClick={findStores}>Find Stores Nearby</button>;
};

2. Native Side ​

The component manages CoreLocation permissions and updates.

swift
Hotwire.registerBridgeComponents([LocationComponent.self])

Released under the MIT License.