スキップしてメイン コンテンツに移動

iBeacon

Turn Your iOS Device or Mac Into a Beacon

Although third-party manufactures can create Bluetooth low energy beacons by programming the beacon’s identity values into the hardware itself, any iOS device or Mac that supports sharing data using Bluetooth low energy can be used as a beacon.
Because turning your iOS device or Mac into a beacon requires the use of the Core Bluetooth framework, be sure to link your app to CoreBluetooth.framework in your Xcode project. To access the classes and headers of the framework, include an #import <CoreBluetooth/CoreBluetooth.h> statement at the top of any relevant source files.

Creating and Advertising a Beacon Region

To use your device as a beacon, you first need to generate a 128-bit UUID that you can use as your beacon region’s proximity UUID. Use the OS X command-line utility uuidgen to easily generate 128-bit UUIDs. To do so, open a window in Terminal. Next type uuidgen on the command line to receive a unique 128-bit value in the form of an ASCII string that is punctuated by hyphens, as in the following example:
$ uuidgen
39ED98FF-2900-441A-802F-9C398FC199D2
Next, create a beacon region using the UUID you generated for the beacon’s proximity UUID, defining the major and minor values as needed. Be sure to also use a unique string identifier for the new region. The following code shows how to create a new beacon region using the example UUID above.
   NSUUID *proximityUUID = [[NSUUID alloc]
      initWithUUIDString:@"39ED98FF-2900-441A-802F-9C398FC199D2"];
 
   // Create the beacon region.
   CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc]
      initWithProximityUUID:proximityUUID
                 identifier:@"com.mycompany.myregion"

コメント

このブログの人気の投稿

日本に来た 今三週間

四月六日に日本に来た、今三週間になった。 嬉しくなかった、悲しくなかった。 日本の携帯電話のカメラはとてもいいよ、私は今撮影が好きだ、いつも寮に帰る途中で花とか魚とか写真を撮る。これも生活の趣味だ。 滴は綺麗だ 桜が凋んで落ちる 天気がいいとき、自転車に乗って、食材を買った。 自分で料理をつくる、おいしそうでしょう。 昨日清水寺に行った、天気はとても熱いね。日に焼けすぎたので、腕は今赤い。 側に花があるので、赤い清水寺はもっと美しそうだ。 木の色は艶やかだ。