Created
June 19, 2012 17:15
-
-
Save EchoAbstract/2955365 to your computer and use it in GitHub Desktop.
Location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is in our CLLocationManagerDelegate | |
// Also, this code builds on https://github.com/Kinvey/KinveyGeoTag | |
// from the blog: http://www.kinvey.com/blog/item/155-ios-corner-taking-your-mobile-local-using-kinvey-for-location-based-apps | |
- (void)locationManager:(CLLocationManager *)manager | |
didUpdateToLocation:(CLLocation *)newLocation | |
fromLocation:(CLLocation *)oldLocation | |
{ | |
// This class assumes that you ask the user if they want to share their location | |
// this should default to false unless the user wants their locations shared. | |
// We use the key kUserWantsToBroadcastLocation (defined elsewhere) to check this | |
NSUserDefaults *defaults = [NSUserDefault standardUserDefaults]; | |
if ([defaults boolForKey:kUserWantsToBroadcastLocation]){ | |
// Get our current user | |
KCSUser *currentUser = [[[KCSClient] sharedClient] currentUser]; | |
// Create a new note with the current location and the username | |
KGAMapNote *newMapUpdate = [[KGAMapNote alloc] initWithCoordinate:newLocation.coordinate | |
title:username]; | |
// Get the collection to save our location | |
KCSCollection *mapNotes = [KCSClient collectionFromString:@"mapNotes" ofClass:[KGAMapNote class]]; | |
// Share the user's location | |
[newMapUpdate saveToCollection:mapNotes withDelegate:self]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment