I am building a demo through Temperature Function.
I am confused about how - (instancetype)initWithBeacon:(CLBeacon *)beacon get connected to the specific iBeacon?
I mean, “beacon” here as a parameter has its own UUID, major and minor, how cold I pass these values to “beacon”?
Following is my code for rewrite this function:
- (instancetype)initWithBeacon:(CLBeacon *)beacon
{
self = [self init];
if (self) {
NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];
self.beaconManager = [[ESTBeaconManager alloc]init];
self.beaconManager.delegate = self;
self.beaconConnection = [ESTBeaconConnection connectionWithProximityUUID:uuid major:30229 minor:30723 delegate:self];
}
return self;
}
I am a beginner in IOS, pls help me.
initWithBeacon
is our own initializer, which we use to pass the beacon selected from the list into the temperature demo. If you’re building your own app, you probably want to do it a little bit differently (hard-coding the UUID/major/minor is a good start), so you’d need to move this code:
NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];
self.beaconConnection = [ESTBeaconConnection connectionWithProximityUUID:uuid major:30229 minor:30723 delegate:self];
… into the viewDidLoad
method.
When I put these lines of code to viewDidLoad
method as:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];
self.beaconConnection = [ESTBeaconConnection connectionWithProximityUUID:uuid major:30229 minor:30723 delegate:self] ;
//[self.activityIndicator startAnimating];
[self.beaconConnection startConnection];
}
A Thread 1 : signal SIGABRT error happened. And if I rewrite the init method as:
-(instancetype)init
{
self = [self init];
if (self) {
NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];
//self.beaconConnection = [[ESTBeaconConnection alloc] initWithProximityUUID:uuid major:30229 minor:30723 delegate:self startImmediately:NO];
self.beaconConnection = [ESTBeaconConnection connectionWithProximityUUID:uuid major:30229 minor:30723 delegate:self] ;
}return self;
}
-(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//[self.activityIndicator startAnimating];
[self.beaconConnection startConnection];
}
I got no error but the app will connecting to iBeacon all the time and nothing else happened.
All in all, I still cannot get temperature from it.
Pls help me.
Can you copy-paste the detailed error description? It should be in the console, like shown on this image:
Hi,
Thanks for help!
This is my GitHub link for this project, which the code have been simplified.
Run it and you will see a error:
2015-04-18 17:14:10.171 Gisdelab[8373:529703] +[ESTRequestBase cloudDomainForCurrentServer]: unrecognized selector sent to class 0x10b1d1b48
2015-04-18 17:14:10.177 Gisdelab[8373:529703] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[ESTRequestBase cloudDomainForCurrentServer]: unrecognized selector sent to class 0x10b1d1b48'
*** First throw call stack:
(
0 CoreFoundation 0x000000010bc3ac65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010b8d3bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010bc41fad +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010bb9813c ___forwarding___ + 988
4 CoreFoundation 0x000000010bb97cd8 _CF_forwarding_prep_0 + 120
5 Gisdelab 0x000000010b160123 +[ESTEstimoteAccount refreshCookieFromCache] + 73
6 Gisdelab 0x000000010b15fe17 +[ESTEstimoteAccount isLoggedIn] + 34
7 Gisdelab 0x000000010b17ab48 -[ESTBeaconConnection performConnection] + 266
8 Gisdelab 0x000000010b11327c -[ViewController viewDidLoad] + 284
9 UIKit 0x000000010c20f210 -[UIViewController loadViewIfRequired] + 738
10 UIKit 0x000000010c20f40e -[UIViewController view] + 27
11 UIKit 0x000000010c12a2c9 -[UIWindow addRootViewControllerViewIfPossible] + 58
12 UIKit 0x000000010c12a68f -[UIWindow _setHidden:forced:] + 247
13 UIKit 0x000000010c136e21 -[UIWindow makeKeyAndVisible] + 42
14 UIKit 0x000000010c0da457 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732
15 UIKit 0x000000010c0dd1de -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
16 UIKit 0x000000010c0dc0d5 -[UIApplication workspaceDidEndTransaction:] + 179
17 FrontBoardServices 0x000000010eb505e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
18 CoreFoundation 0x000000010bb6e41c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
19 CoreFoundation 0x000000010bb64165 __CFRunLoopDoBlocks + 341
20 CoreFoundation 0x000000010bb63f25 __CFRunLoopRun + 2389
21 CoreFoundation 0x000000010bb63366 CFRunLoopRunSpecific + 470
22 UIKit 0x000000010c0dbb42 -[UIApplication _run] + 413
23 UIKit 0x000000010c0de900 UIApplicationMain + 1282
24 Gisdelab 0x000000010b11407f main + 111
25 libdyld.dylib 0x000000010d917145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Looking forward for your reply!
Shu
Looks like you have both the Estimote SDK 2.4 and 3.0 in a single project, which probably leads to some conflicts and the crash. I’d recommend removing the old one and migrating entirely to SDK 3 (:
Thanks very very much, I finally succeed after I followed your instruction.
Additional question:
Is there any method could I connect to iBeacon from cloud? I mean get the temperature data from cloud wherever my mobile device is?
Anyway, thanks for your help and excellent SDK!
Hmm, that’d require some device to be constantly connected to the beacon and streaming the temperature readings to the server. We don’t have a ready-made solution for that though, so it’d be up to you to code up something like this.