Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #108 and also added support alt beacon layout. #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class FlutterBeaconPlugin implements FlutterPlugin, ActivityAware, Method

private static final BeaconParser iBeaconLayout = new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
public static final BeaconParser altBeaconLayout = new BeaconParser().
setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");

static final int REQUEST_CODE_LOCATION = 1234;
static final int REQUEST_CODE_BLUETOOTH = 5678;
Expand Down Expand Up @@ -107,6 +109,8 @@ private void setupChannels(BinaryMessenger messenger, Activity activity) {
if (!beaconManager.getBeaconParsers().contains(iBeaconLayout)) {
beaconManager.getBeaconParsers().clear();
beaconManager.getBeaconParsers().add(iBeaconLayout);
beaconManager.getBeaconParsers().add(altBeaconLayout);

}

platform = new FlutterPlatform(activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void startRanging() {
for (Region region : regionRanging) {
plugin.getBeaconManager().startRangingBeaconsInRegion(region);
}

}
} catch (RemoteException e) {
if (eventSinkRanging != null) {
Expand Down
7 changes: 6 additions & 1 deletion ios/Classes/FlutterBeaconPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ - (id)init {
// so set this as the default to stay backwards compatible.
self.defaultLocationAuthorizationType = kCLAuthorizationStatusAuthorizedAlways;
}
self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];
return self;
}

Expand Down Expand Up @@ -301,7 +302,10 @@ - (void) startBroadcast:(id)arguments {

self.shouldStartAdvertise = YES;
self.beaconPeripheralData = [region peripheralDataWithMeasuredPower:measuredPower];
self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];
if (self.peripheralManager) {
[self.peripheralManager startAdvertising:(self.beaconPeripheralData)];
}

}

///------------------------------------------------------------
Expand Down Expand Up @@ -332,6 +336,7 @@ - (void) startRangingBeaconWithCall:(id)arguments {

- (void) stopRangingBeacon {
for (CLBeaconRegion *region in self.regionRanging) {
NSLog(@"STOP: %@", region);
[self.locationManager stopRangingBeaconsInRegion:region];
}
self.flutterEventSinkRanging = nil;
Expand Down