iOS-Integration

Location:

Start Location Tracking

You can start tracking the user location by using startTracking() method.

                                
  GeoSpark.startTracking()
  [GeoSpark startTracking];  
                               
                            

Stop Location Tracking

You can start tracking the user location by using stopTracking() method.

                                
  GeoSpark.stopTracking()
  [GeoSpark stopTracking];  
                               
                            

Location listener

Implement GeoSparkDelegate in AppDelegate , that will be initialized and executed in the background.

                                
  GeoSpark.delegate = self
  [GeoSpark setDelegate:self];  
                               
                            

Trip:

Start Trip

Once user start tracking location , you can use startTrip method.

                                
  GeoSpark.startTrip({ (trip) in
   // Trip id , start time
   // trip.tripId
   //trip.trip_started_at
   }, onFailure: { (error) in
   // error.errorCode
   // error.errorMessage
   })
   [GeoSpark startTrip:^(GeoSparkTrip * trip) {
     // Trip id , start time
     //trip.tripId
     //trip.trip_started_at
     } onFailure:^(GeoSparkError * error) {
     // error.errorCode
     // error.errorMessage
     }];
                               
                            

End Trip

Once the trip started , you can stop the trip using TRIPID

                                
   GeoSpark.endTrip("TRIPID", { (trip) in
     // Trip id , ended time
     // trip.tripId
     // trip.trip_ended_at
     }, onFailure: { (error) in
     // error.errorCode
     // error.errorMessage
     })
   [GeoSpark endTrip:@"TRIPID" :^(GeoSparkTrip * trip) {
     // Trip id , ended time
     // trip.tripId
     // trip.trip_ended_at
     } onFailure:^(GeoSparkError * error) {
     // error.errorCode
     // error.errorMessage
     }];
                               
                            

Active Trips

By using activeTrips method you can see active trips of the user.

                                
  GeoSpark.activeTrips({ (trips) in
     // List of tripid, started time
     // trips.data[0].tripId
     // trips.data[0].tripStartedAt
     }, onFailure: { (trips) in
     // error.errorCode
     // error.errorMessage
    })
  [GeoSpark activeTrips:^(GeoSparkTrips * trips) {
     // List of tripid, started time
     // trips.data[0].tripId
     // trips.data[0].tripStartedAt
     } onFailure:^(GeoSparkError * error) {
     // error.errorCode
     // error.errorMessage
     }];;
                               
                            

Geofence:

Create Geofence

Create Geofence in GeoSpark SDK, using createGeofence() method.

Make sure radius should be (50 -1000 meters) and set expiry time less than 24hrs.

                                
  GeoSpark.createGeofence(latitude: latitude, longitude: logitude, expiry:
  expiry, radius: radius, { (geofence) in
   // geofence.create_at
   // geofence.expire_at
   // geofence.geofence_id
   // geofence.geometry_radius
   // geofence.coordinate
   }, onFailure: { (error) in
   // error.errorCode
   // error.errorMessage
   })
  [GeoSpark createGeofenceWithLatitude:latitude longitude:longitude
  expiry:expiry radius:radius :^(GeoSparkGeofence * geofence) {
   // geofence.create_at
   // geofence.expire_at
   // geofence.geofence_id
   // geofence.geometry_radius
   // geofence.coordinate
   } onFailure:^(GeoSparkError * error) {
   // error.errorCode
   // error.errorMessage
   }];
                               
                            

Geofence List

To see the user created Geofence using this eofenceList

                                
  GeoSpark.geofenceList({ (geofenceLists) in
   //geofenceList.data.count
   }, onFailure: { (error) in
   // error.errorCode
   // error.errorMessage
  })
  [GeoSpark geofenceList:^(GeoSparkGeofenceList * geofenceList) {
   //geofenceList.data.count
   } onFailure:^(GeoSparkError * error) {
   // error.errorCode
   // error.errorMessage
   }];