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

support rn > 0.40 #55

Open
wants to merge 2 commits 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
2 changes: 1 addition & 1 deletion RNBeacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Geniux Consulting. All rights reserved.
//

#import "RCTBridgeModule.h"
#import <React/RCTBridgeModule.h>

@interface RNBeacon : NSObject <RCTBridgeModule>

Expand Down
46 changes: 23 additions & 23 deletions RNBeacon.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#import <CoreLocation/CoreLocation.h>

#import "RCTBridge.h"
#import "RCTConvert.h"
#import "RCTEventDispatcher.h"
#import <React/RCTBridge.h>
#import <React/RCTConvert.h>
#import <React/RCTEventDispatcher.h>

#import "RNBeacon.h"

Expand All @@ -33,12 +33,12 @@ - (instancetype)init
{
if (self = [super init]) {
self.locationManager = [[CLLocationManager alloc] init];

self.locationManager.delegate = self;
self.locationManager.pausesLocationUpdatesAutomatically = NO;
self.dropEmptyRanges = NO;
}

return self;
}

Expand All @@ -47,38 +47,38 @@ - (instancetype)init
- (CLBeaconRegion *) createBeaconRegion: (NSString *) identifier uuid: (NSString *) uuid major: (NSInteger) major minor:(NSInteger) minor
{
NSUUID *beaconUUID = [[NSUUID alloc] initWithUUIDString:uuid];

unsigned short mj = (unsigned short) major;
unsigned short mi = (unsigned short) minor;

CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:beaconUUID major:mj minor:mi identifier:identifier];

beaconRegion.notifyEntryStateOnDisplay = YES;

return beaconRegion;
}

- (CLBeaconRegion *) createBeaconRegion: (NSString *) identifier uuid: (NSString *) uuid major: (NSInteger) major
{
NSUUID *beaconUUID = [[NSUUID alloc] initWithUUIDString:uuid];

unsigned short mj = (unsigned short) major;

CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:beaconUUID major:mj identifier:identifier];

beaconRegion.notifyEntryStateOnDisplay = YES;

return beaconRegion;
}

- (CLBeaconRegion *) createBeaconRegion: (NSString *) identifier uuid: (NSString *) uuid
{
NSUUID *beaconUUID = [[NSUUID alloc] initWithUUIDString:uuid];

CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:beaconUUID identifier:identifier];

beaconRegion.notifyEntryStateOnDisplay = YES;

return beaconRegion;
}

Expand Down Expand Up @@ -187,7 +187,7 @@ -(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus
}

- (void)locationManager:(CLLocationManager *)manager rangingBeaconsDidFailForRegion:(CLBeaconRegion *)region withError:(NSError *)error
{
{
NSLog(@"Failed ranging region: %@", error);
}

Expand All @@ -206,27 +206,27 @@ -(void) locationManager:(CLLocationManager *)manager didRangeBeacons:
return;
}
NSMutableArray *beaconArray = [[NSMutableArray alloc] init];

for (CLBeacon *beacon in beacons) {
[beaconArray addObject:@{
@"uuid": [beacon.proximityUUID UUIDString],
@"major": beacon.major,
@"minor": beacon.minor,

@"rssi": [NSNumber numberWithLong:beacon.rssi],
@"proximity": [self stringForProximity: beacon.proximity],
@"accuracy": [NSNumber numberWithDouble: beacon.accuracy]
}];
}

NSDictionary *event = @{
@"region": @{
@"identifier": region.identifier,
@"uuid": [region.proximityUUID UUIDString],
},
@"beacons": beaconArray
};

[self.bridge.eventDispatcher sendDeviceEventWithName:@"beaconsDidRange" body:event];
}

Expand All @@ -236,7 +236,7 @@ -(void)locationManager:(CLLocationManager *)manager
@"region": region.identifier,
@"uuid": [region.proximityUUID UUIDString],
};

[self.bridge.eventDispatcher sendDeviceEventWithName:@"regionDidEnter" body:event];
}

Expand All @@ -246,7 +246,7 @@ -(void)locationManager:(CLLocationManager *)manager
@"region": region.identifier,
@"uuid": [region.proximityUUID UUIDString],
};

[self.bridge.eventDispatcher sendDeviceEventWithName:@"regionDidExit" body:event];
}

Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"name": "react-native-ibeacon",
"version": "0.6.0",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "https://github.com/geniuxconsulting/react-native-ibeacon.git"
},
"license": "MIT",
"keywords": ["react-native", "react-component", "ios", "ibeacon", "beacon"],
"keywords": [
"react-native",
"react-component",
"ios",
"ibeacon",
"beacon"
],
"main": "RNBeacon.ios.js"
}