androidiosbluetoothibeaconeddystone

Android Device to Act as Beacon


I am sorry if this question is not an "SO approved" type of question.

I would like to develop an app that act as a beacon (among of other functionality). This app will be installed on an Android device.

I am very new at all these Bluetooth programming and I would like to get some answers on these questions:

  1. Can anyone point me on the right part as where to start?

  2. How client app get notification from the beacon? Can anyone explain how it works?

Thank you and sorry for these questions.


Solution

  • A few points:

    To illustrate the point about how you send local notifications based on beacon identifiers, here is some sample code for iOS. This code runs on the client app. The Beacon simply sends out a transmission with specific beacon identifiers, and the client app reads them and acts appropriately.

    var lastNotificationTime = NSDate(timeIntervalSince1970: 0) // Initialize last Notification time to a long time ago
    
    func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
      // Only send notification if we have not done so in the last hour (3600 seconds)
      if (lastNotificationTime.timeIntervalSinceNow < -3600.0) {
        for beacon in beacons {
          // Send a 20% off notification for beacon with identifiers major 1, minor 2
          if beacon.major.intValue == 1 && beacon.minor.intValue == 2 {
            let localNotification = UILocalNotification()
            localNotification.alertTitle = "Discount 20% on all items"
            dispatch_async(dispatch_get_main_queue()) {
              UIApplication.sharedApplication().presentLocalNotificationNow(localNotification)
            }
          }
        }
      }
    }
    

    Full Disclosure: I am the lead developer on the Android Beacon Library open source project and the author of the Locate app.