Skip to content

Instantly share code, notes, and snippets.

View stevenou's full-sized avatar

Steven Ou stevenou

  • Whitehawk Ventures
  • San Francisco
View GitHub Profile
@stevenou
stevenou / GeolocationModule.mm
Created February 14, 2012 21:15
Geofencing in Titanium
// this file located in /Library/Application Support/Titanium/mobilesdk/osx/{version_number}
// add the following methods to GeolocationModule.mm
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES),@"success",[NSDictionary dictionaryWithObjectsAndKeys:NUMDOUBLE(region.center.latitude),@"lat",NUMDOUBLE(region.center.longitude),@"lng",NUMDOUBLE(region.radius),@"radius",region.identifier,@"identifier",nil],@"region",nil];
if ([self _hasListeners:@"enteredRegion"])
{
[self fireEvent:@"enteredRegion" withObject:event];