How to control the bluetooth signal in my ibeacons?

Hello !, I’m doing with the method of sending proximity to different web pages depending on distance of the iBeacon . The problem is that whenever issues bluetooth signal reloads the page in case Immediate. This is a part of my code:

   case .Far:
       distance = "far"
      // return distance
   case .Near:
       distance = "Near"
      // return distance

   case .Immediate:
       distance = "Immediate"
       webView.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)
       let url = NSURL(string: "http:/")
       let request = NSURLRequest(URL:url!)
       buttonWeb = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: "finished")
       navigationItem.setRightBarButtonItem(buttonWeb, animated: true)

       var notification1 : UILocalNotification = UILocalNotification()
       notification1.alertAction = "hello"
       notification1.soundName = UILocalNotificationDefaultSoundName;
       notification1.alertBody = "wellcome"

       println("Usted esta entrando")

       if(distance == "Immediate"){
           var cont:uint = 0
           cont += 1
       }else{ return distance }
    //   return distance

I assume this is inside the didRangeBeacons method. The thing is, this method will be called every second with the latest measurement of the beacon’s proximity. If you put the code responsible for displaying a web page here, it’ll trigger every second, resulting in reloads.

This means you’ll need to come up with a bit smarter condition to show the web page. One possibility: only trigger it the proximity changed from something to immediate. For example:

// define this somewhere in your class
var previousProximity: CLProximity?

// modify the code:
switch {
    // ...
    case .Immediate:
        if (self.previousProximity != proximity) {
            // show the web page
// add this after the switch
self.previousProximity = proximity;

This may still be non-ideal though—if the person browsing the webpage moves away from the beacon, and then comes back, it’ll still reload the page. So another idea would be not to re-display the web view until the user presses the “done” button.