spezilocation
Spezi Module for Using Location Data in Mobile Applications
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.4%) to scientific vocabulary
Repository
Spezi Module for Using Location Data in Mobile Applications
Basic Info
Statistics
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
Spezi Location
Overview
The Spezi Location Module allows you to access location data from within your Stanford Spezi app via Apple's CoreLocation service using a simple asynchronous API.
Setup
1. Add Spezi Location as a Dependency
You need to add the SpeziLocation Swift package to your app in Xcode or Swift package.
[!IMPORTANT]
If your application is not yet configured to use Spezi, follow the Spezi setup article to set up the core Spezi infrastructure.
2. Configure the SpeziLocation module in the SpeziAppDelegate.
```swift import Spezi import SpeziLocation
class ExampleDelegate: SpeziAppDelegate { override var configuration: Configuration { Configuration { SpeziLocation() } } } ```
3. Configure your Xcode project for Location Access
Before requesting permissions for location access from your user, you will need to provide descriptions of how your app uses location services in your Info.plist file:
- Open your project settings in Xcode by selecting PROJECTNAME > TARGETNAME > Info tab.
- Under
Custom iOS Target Properties(theInfo.plistfile), add one or more of the following keys depending on the level of location access you are requesting and add a description for your usage in theValuecolumn which will be shown to the user when you request access:
| Property | Description |
|----------|-------------|
| Privacy - Location When In Use Usage Description | Access to location while the app is in use (in the foreground). |
| Privacy - Location Always and When In Use Usage Description | Access to location both when the app is in use and in the background. |
Usage
Request the User's Current Location
The following example demonstrates how you can use SpeziLocation in a SwiftUI view to request access to the user's current location.
```swift import CoreLocation import SpeziLocation import SwiftUI
struct LocationPermissionsView: View { @Environment(SpeziLocation.self) private var speziLocation
var body: some View {
Button("Request Location Access") {
Task {
do {
// Request permission to access location while the app is in use
let result = await speziLocation.requestWhenInUseAuthorization()
// Check if permission was granted
if (result == .authorizedWhenInUse) {
// Get the user's latest location
let location = try await speziLocation.getLatestLocation()
// Extract the latitude and longitude
let latitude = location.coordinate.latitude
let longitude = location.coordinate.longitude
}
} catch {
// Handle error...
}
}
}
}
} ```
License
This project is licensed under the MIT License. See Licenses for more information.
Contributors
This project is developed as part of the Stanford Mussallem Center for Biodesign at Stanford University. See CONTRIBUTORS.md for a full list of all SpeziLocation contributors.

Owner
- Name: Stanford Spezi
- Login: StanfordSpezi
- Kind: organization
- Repositories: 1
- Profile: https://github.com/StanfordSpezi
Citation (CITATION.cff)
# # This source file is part of the SpeziLocation open source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT # cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Ravi" given-names: "Vishnu" orcid: "https://orcid.org/0000-0003-0359-1275" - family-names: "Schmiedmayer" given-names: "Paul" orcid: "https://orcid.org/0000-0002-8607-9148" title: "SpeziLocation" doi: 10.5281/zenodo.7538165 url: "https://github.com/StanfordBDHG/SwiftPackageTemplate"
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Vishnu Ravi | v****i@g****m | 7 |
| Paul Schmiedmayer | P****r | 1 |
Issues and Pull Requests
Last synced: 8 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0