Skip to content

Commit

Permalink
Merge pull request #44 from williamrijksen/set-notify-on-awake
Browse files Browse the repository at this point in the history
Make notifyEntryStateOnDisplay optional
  • Loading branch information
jbeuckm authored Sep 19, 2016
2 parents d07b497 + 96bc327 commit f2ae0b8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
25 changes: 12 additions & 13 deletions Classes/OrgBeuckmanTibeaconsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,25 @@ - (void)startMonitoringForRegion:(id)args
-(void)stopMonitoringAllRegions:(id)args
{
ENSURE_UI_THREAD_1_ARG(args);
ENSURE_SINGLE_ARG(args, NSDictionary);

NSArray *regions = [self.locationManager.monitoredRegions allObjects];

for (CLBeaconRegion *region in regions) {
for(id region in self.locationManager.monitoredRegions) {
[self.locationManager stopMonitoringForRegion:region];
}
[regions release];

NSLog(@"[INFO] Turned off monitoring in ALL regions.");
}

-(void)stopMonitoringRegion:(id)args
{
ENSURE_UI_THREAD_1_ARG(args);
ENSURE_SINGLE_ARG(args, NSDictionary);

CLBeaconRegion *region = [self regionForArgs:args];

NSLog(@"[INFO] Turning off region monitoring in %@", region);

[self.locationManager stopMonitoringForRegion:region];
}

#pragma mark - Beacon monitoring delegate methods

Expand Down Expand Up @@ -254,10 +260,6 @@ - (CLBeaconRegion *)createBeaconRegionWithUUID:(NSString *)uuid major:(NSInteger

[proximityUUID release];

region.notifyEntryStateOnDisplay = true;
region.notifyOnEntry = true;
region.notifyOnExit = true;

return [region autorelease];
}

Expand Down Expand Up @@ -314,18 +316,15 @@ - (CLBeaconRegion *)regionForArgs:(id)args
- (void)stopRangingForAllBeacons:(id)args
{
ENSURE_UI_THREAD_1_ARG(args);
ENSURE_SINGLE_ARG(args, NSDictionary);

if (self.locationManager.rangedRegions.count == 0) {
NSLog(@"[INFO] Didn't turn off ranging: Ranging already off.");
return;
}

NSArray *regions = [self.locationManager.rangedRegions allObjects];
for (CLBeaconRegion *region in regions) {
for (id region in self.locationManager.rangedRegions) {
[self.locationManager stopRangingBeaconsInRegion:region];
}
[regions release];

NSLog(@"[INFO] Turned off ranging in ALL regions.");
}
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ TiBeacons.startMonitoringForRegion({
major: 1,
minor: 2
});

// To stop monitoring one single region
TiBeacons.stopMonitoringRegion({
uuid : "00000000-0000-0000-0000-000000000002",
identifier : "Test Region 3 (device-specific)",
major: 1,
minor: 2
});

// To monitor regions and get notified on awake the iPhone
TiBeacons.startMonitoringRegion({
uuid : "00000000-0000-0000-0000-000000000002",
identifier : "Test Region 3 (device-specific)",
major: 1,
minor: 2,
notifyEntryStateOnDisplay: "YES"
});

// To stop monitoring all regions
TiBeacons.stopMonitoringAllRegions();

// Make sure you stopped ranging all beacons after stop monitoring
TiBeacons.stopRangingForAllBeacons();
```

Listen for region events:
Expand Down
4 changes: 2 additions & 2 deletions manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 0.10.0
version: 0.11.0
apiversion: 2
description: Implements iBeacon monitoring and ranging and advertising
author: Joe Beuckman
Expand All @@ -15,4 +15,4 @@ name: TiBeacons
moduleid: org.beuckman.tibeacons
guid: 8d388e36-9093-4df8-a4d3-1db3621f04c0
platform: iphone
minsdk: 3.0.0.GA
minsdk: 3.5.0.GA
Binary file added org.beuckman.tibeacons-iphone-0.10.1.zip
Binary file not shown.
Binary file added org.beuckman.tibeacons-iphone-0.11.0.zip
Binary file not shown.

0 comments on commit f2ae0b8

Please sign in to comment.