Skip to content

JSingh950/CampusShield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ Campus Shield

A live GPS emergency safety app for NJIT students built with SwiftUI.

Campus Shield connects students directly to NJIT Public Safety with one tap — sharing real-time GPS coordinates, enabling emergency chat with media sharing, and providing multiple discreet SOS triggers including volume buttons, shake detection, back tap, a lock screen widget, and a Siri shortcut.


Features

🚨 Emergency Dial

  • One-tap connect to NJIT Public Safety (973-596-3111)
  • Auto-dials on emergency activation
  • Call 911 and Text 911 buttons available in the dashboard
  • Automated 911 text includes live GPS coordinates, accuracy, elevation, and direct Apple Maps + Google Maps links

📍 Live GPS Tracking

  • Real-time latitude, longitude, altitude, speed, and accuracy
  • Barometric altimeter (relative) with GPS absolute fallback
  • Sea level elevation display (WGS84)
  • GPS accuracy tier system: Excellent / Good / Fair / Signal Lost
  • Location silently starts on app launch so coordinates are ready immediately

💬 Emergency Chat

  • Real-time message interface with NJIT Public Safety
  • Quick reply buttons for common emergency phrases
  • Photo and video sharing via camera capture or photo library
  • Full-screen photo preview
  • iCloud video support via PHImageManager

🆘 SOS Triggers

Multiple ways to activate the emergency line:

Trigger Works When
Spam volume button (3×) + shake (3×) within 3 seconds App is open
Double tap back of phone App is open
Lock screen widget tap Anywhere — no unlock needed
Back Tap → Shortcuts deep link Anywhere (one-time setup)

🔒 Lock Screen & Home Screen Widget

Three widget sizes — lock screen circular, lock screen rectangular, and home screen small tile — all one tap away from the emergency dial.


Screenshots

Add screenshots here


Requirements

  • iOS 16.0+
  • Xcode 15+
  • Real iPhone required (GPS, camera, and accelerometer do not work in the simulator)

Setup

1. Clone the repo

git clone https://github.com/yourusername/campus-shield.git
cd campus-shield

2. Open in Xcode

open CampusShield.xcodeproj

3. Add Info.plist privacy keys

Add the following keys to your Info.plist:

Key Purpose
NSCameraUsageDescription Camera access for photo/video capture
NSMicrophoneUsageDescription Microphone access for video recording
NSPhotoLibraryUsageDescription Photo library read access
NSPhotoLibraryAddUsageDescription Full photo library access
NSLocationWhenInUseUsageDescription GPS tracking
NSLocationAlwaysAndWhenInUseUsageDescription Background GPS tracking
NSMotionUsageDescription Shake and back tap SOS detection

4. Enable capabilities

In Xcode → Target → Signing & Capabilities:

  • Add Background Modes → check Location updates

5. Register URL scheme

In Xcode → Target → Info tab → URL Types → add:

  • Identifier: com.campusshield.app
  • URL Schemes: campusshield

6. Add the Widget Extension

  1. File → New → Target → Widget Extension
  2. Name: CampusShieldWidget
  3. Uncheck "Include Live Activity" and "Include Configuration App Intent"
  4. Replace the generated Swift file contents with NJITSafetyWidget.swift

7. Build and run to a real device

Select your iPhone as the build target and hit Run.


Back Tap Setup (Background SOS)

To enable double-tapping the back of your phone as an SOS trigger from anywhere on the device:

  1. Open the Shortcuts app
  2. Tap + → Add Action → search Open URLs → enter campusshield://sos
  3. Name the shortcut Campus Shield SOS
  4. Go to Settings → Accessibility → Touch → Back Tap → Double Tap
  5. Select Campus Shield SOS

A step-by-step guide is also built into the app on the start screen.


Architecture

CampusShield/
├── Models
│   ├── ChatMessage         # Text + optional media attachment
│   ├── GPSReading          # Location data with computed properties
│   └── MediaAttachment     # Photo or video enum
│
├── Managers
│   ├── LocationManager     # CLLocationManager + CMAltimeter
│   └── SOSTriggerManager   # Volume + shake + back tap detection
│
├── Views
│   ├── ContentView         # Root — routes start vs emergency
│   ├── StartScreenView     # Launch screen with SOS hints
│   ├── EmergencyDashboardView  # Active emergency UI
│   └── BackTapSetupView    # Step-by-step Back Tap guide
│
├── Components
│   ├── ChatBubbleView      # Text and media bubbles
│   ├── CoordCell           # GPS coordinate display cell
│   ├── StatusPill          # Voice / GPS status indicators
│   └── SetupStep           # Numbered step card
│
├── Pickers
│   ├── MediaPicker         # PHPickerViewController wrapper
│   └── CameraPicker        # UIImagePickerController wrapper
│
└── Widget
    └── NJITSafetyWidget    # Lock screen + home screen widgets

Emergency Contacts

Contact Number
NJIT Public Safety 973-596-3111
Emergency 911

Roadmap

  • Firebase backend for real-time media delivery to dispatch
  • Apple Watch companion app for gesture-based background SOS
  • Push notifications from dispatch to user
  • Incident history log
  • Multi-campus support

Contributing

Pull requests are welcome. For major changes please open an issue first to discuss what you'd like to change.


License

MIT


Built for NJIT student safety. Not an official NJIT product.

About

Campus Shield is a campus safety app that connects the user to NJIT public safety. It sends 3D pin positioning to public safety and allows for a nonverbal form of communication through a chatbox and also be able to share media with them to show your location. There is also an option to call and text 911 in case public safety doesnt pick up.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages