`
sillycat
  • 浏览: 2486659 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

IOS7 App Development Essentials(2)iBeacon

 
阅读更多

IOS7 App Development Essentials(2)iBeacon

1. Beacon Introduction
CLBeacon
RSSI(Received Signal Strength Indication)  [-93, -113]
accuracy    The accuracy of the proximity value, measured in meters from the beacon
proximity    The relative distance to the beacon.

2. Building Steps
General ——> Linked Frameworks and Libraries
I should add these features before I begin.
CoreLocation.framework
CoreBluetooth.framework

Here is the interface in project EasyUIApp.

#import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> #import <CoreBluetooth/CoreBluetooth.h>@interface EABeaconsViewController : UIViewController <CLLocationManagerDelegate, CBPeripheralManagerDelegate, UITableViewDataSource, UITableViewDelegate]]> @property (nonatomic,weak) IBOutletUISwitch *advertisingSwitch; @property (nonatomic,weak) IBOutletUISwitch *monitorSwitch; @property (nonatomic,weak) IBOutletUISwitch *rangingSwitch; @property (nonatomic,weak) IBOutletUITableView *beaconTableView; @end

The import Implementation are as follow:
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region {

//enter region - (void)locationManager:(CLLocationManager *)manager         didEnterRegion:(CLRegion *)region{ } //exit region - (void)locationManager:(CLLocationManager *)manager          didExitRegion:(CLRegion *)region{ }

//ranging beacon - (void)locationManager:(CLLocationManager *)manager        didRangeBeacons:(NSArray *)beacons               inRegion:(CLBeaconRegion *)region {

Tips
1. Update the iOS Version
Check your phone model 
http://support.apple.com/kb/ht3939
My phone model is A1428 at the back cover, it is GSM model.

Download the beta version
https://developer.apple.com/devcenter/ios/index.action#betadownloads

Both for Xcode and iOS
ios_7.1_beta_5__iphone_5_model_a1428__11d5145e.dmg
xcode_5.1_beta5.dmg

Press ‘Option’ and click on the ‘Restore IPhone'

2. Downgrade the iOS 7.1 beta to iOS 7.0.x
First of all, prepare and download the latest 7.0.x version from developer center.
iPhone5,1_7.0.6_11B651_Restore.ipsw

Hold the “Home” button and the “Power” button for 10 seconds, then release the “Power” button. The iTunes will show you that the iPhone is under Recovery Mode.

Hold the ‘alt’ ‘option’ button on my MAC book. Click on the ‘Restore IPhone’ on the iTunes. Select my lovely ipsw file.



3. Detect the App Foreground and Background
+ (void)load {    [[NSNotificationCenterdefaultCenter] addObserver:self            selector:@selector(handleAppLaunched) name:UIApplicationDidFinishLaunchingNotificationobject:nil];        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(handleAppResigningActive) name:UIApplicationWillResignActiveNotificationobject:nil];        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(handleAppBecomingActive) name:UIApplicationDidBecomeActiveNotificationobject:nil];        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(handleAppEnteringBackground) name:UIApplicationDidEnterBackgroundNotificationobject:nil];        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(handleAppEnteringForeground) name:UIApplicationWillEnterForegroundNotificationobject:nil];        [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(handleAppClosing) name:UIApplicationWillTerminateNotificationobject:nil]; } + (void)handleAppLaunched{    NSLog(@"I am handleAppLaunched....."); } + (void)handleAppResigningActive{    NSLog(@"I am handleAppResigningActive....."); } + (void)handleAppBecomingActive{    NSLog(@"I am handleAppBecomingActive....."); } + (void)handleAppEnteringBackground{    NSLog(@"I am handleAppEnteringBackground....."); } + (void)handleAppEnteringForeground{    NSLog(@"I am handleAppEnteringForeground....."); } + (void)handleAppClosing{    NSLog(@"I am handleAppClosing....."); }

Or I can change all the method from + class method to - instance method, and call the method in my startMethod or -(void)viewDidLoad.


References:
http://code-evolution.blogspot.com/2011/02/evolved-code-2-splendid-approach-for.html


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics