Simple iOS App for tracking using Firebase Real-time database

1 -Create blank application in Xcode

2- Install CocoaPods on your Mac

As you’ve already installed CocoaPods, if not click on to link and follow the simple steps.
https://guides.cocoapods.org/using/getting-started.html 

3- Add CocoaPods in App

Open Terminal and open your application folder then write command
pod init

You will get a text file named Podfile in your project folder.

 

4- Add Firebase & Google

Add Firebase and Google maps into the pod file and install.
Open the Podfile in a text editor and add pods then execute this command.

pod install

 # Pods for Rider
 pod ‘Firebase/Database’
 pod ‘GoogleMaps’

 

5- Open Firebase Console

Open the Firebase console and create a new project.
https://firebase.google.com

6- Add iOS App in Firebase

Add the iOS application in Firebase project and connect with Xcode by download google.plist file.
Add the .plist file in your project directory.

 

7- Add into your Class

Add CLLocationManagerDelegate in your ViewConrtoller Class.
https://developer.apple.com/documentation/corelocation/cllocationmanager

Implement didupdatelocation method
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
  {
}

 

8- Get Location

Get the current location from LocationManager method didUpdateLocation with location of every 10 meters.

locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
  {    self.currentLocation = locations.last}

9- Add Location

Add the current location to firebase database.

self.currentLocation = locations.last 
tref?.setValue([“latlong” : [“lat” : currentLocation.coordinate.latitude , “long” : currentLocation.coordinate.longitude]])

Run and check if the location is updated.

Repeat all the above steps and create another new application in Xcode

10- Add Google maps

Add Google maps on your home screen that displays current location.
https://developers.google.com/maps/documentation/ios-sdk/start

11- Add Firebase Observer

Add the Firebase observer (Real-time Firebase database read function). Get the latitude and longitude values from the real time firebase database.
Move the marker on map according to the latest values of longitude and latitude.
https://firebase.google.com/docs/database/ios/read-and-write

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Let’s Socialize

Popular Post

Share

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on tumblr
Tumblr
Share on skype
Skype
Share on whatsapp
WhatsApp

Flutter vs. React Native

Flutter: Flutter is a UI toolkit used for crafting beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. Flutter is not

Read More »
0
Would love your thoughts, please comment.x
()
x