nativephp / geolocation
Geolocation plugin for NativePHP Mobile - GPS location and permission handling
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Kotlin
Type:nativephp-plugin
pkg:composer/nativephp/geolocation
Requires
- php: ^8.2
- nativephp/mobile: *
Requires (Dev)
- pestphp/pest: ^3.0
README
GPS location and permission handling for NativePHP Mobile applications.
Installation
# Install the package composer require nativephp/geolocation # Publish the plugins provider (first time only) php artisan vendor:publish --tag=nativephp-plugins-provider # Register the plugin php artisan native:plugin:register nativephp/geolocation # Verify registration php artisan native:plugin:list
This adds \NativePHP\Geolocation\GeolocationServiceProvider::class to your plugins() array.
Usage
use NativePHP\Geolocation\Facades\Geolocation; // Get current position with high accuracy Geolocation::getCurrentPosition() ->fineAccuracy() ->id('my-location-request') ->get(); // Check permission status Geolocation::checkPermissions()->get(); // Request permissions Geolocation::requestPermissions()->get();
Listening for Events
use Livewire\Component; use Native\Mobile\Attributes\OnNative; use NativePHP\Geolocation\Events\LocationReceived; class LocationTracker extends Component { public ?float $latitude = null; public ?float $longitude = null; #[OnNative(LocationReceived::class)] public function handleLocation( bool $success, ?float $latitude, ?float $longitude, ?float $accuracy, ?int $timestamp, ?string $provider, ?string $error, ?string $id ) { if ($success) { $this->latitude = $latitude; $this->longitude = $longitude; } } }
Events
| Event | Description |
|---|---|
LocationReceived |
Fired when location is received |
PermissionStatusReceived |
Fired when permission check completes |
PermissionRequestResult |
Fired when permission request completes |
Permissions
Android
android.permission.ACCESS_FINE_LOCATIONandroid.permission.ACCESS_COARSE_LOCATION
iOS
NSLocationWhenInUseUsageDescriptionNSLocationAlwaysAndWhenInUseUsageDescription
License
MIT