2016-09-22 2 views
0

누구든지 "IOS10에서 신호등이 작동하지 않습니다."문제를 해결하는 데 도움을 주시기 바랍니다. 아래의 링크 Ranging Beacons in iOS 10에 지정된 블루투스 디바이스에 설정되어IOS에서 비컨 크래시 10

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

    @try { 

     CLBeacon *beacon = [[CLBeacon alloc] init]; 

     NSLog(@"beacons Count %lu", (unsigned long)beacons.count); 


    if(beacons != nil && beacons != Nil && beacons != NULL && beacons.count > 0) { 

     beacon = [beacons firstObject]; 

    self.currentMajor = beacon.major; 
    self.currentMinor = beacon.minor; 

    NSArray *majorMinorIDs = [[NSArray alloc]initWithObjects:self.currentMajor,self.currentMinor, nil]; 
    self.ComaSeparatedIDS = [majorMinorIDs componentsJoinedByString:@","]; 

    /* Log */ 
    [self printLog:[NSString stringWithFormat:@"Current Major Id: %@, Previous Major Id: %@, Current Minor Id: %@, Previous Minor Id %@", self.currentMajor, self.prevMajor, self.currentMinor, self.prevMinor]]; 

    // Make a web service request only if new beacon is detected 
    if((([self.prevMajor intValue]!=[self.currentMajor intValue]) || ([self.prevMinor intValue]!=[self.currentMinor intValue])) || (self.enteredRegionNow)) 
    { 
     NSLog(@"Making url request when new beacon detected"); 
     // Delete all the urls before calling the web service 
     self.url_immediate = nil; 
     self.url_near = nil; 
     self.url_far = nil; 
     self.url_exit = nil; 

     // Make a web service request to the server 
     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://ibeacon.bpsqr.me/GetUrls/?UUID=%@&MinorID=%@&MajorID=%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"UUID"], self.currentMinor, self.currentMajor]]]; 
     self.urlsRequestConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

     self.prevMajor = self.currentMajor; 
     self.prevMinor = self.currentMinor; 

     self.enteredRegionNow = false; 


     return; 
    } 

    // Assigning beacon's current proximity 
    self.currentProximity = beacon.proximity; 
    [self printLog:[NSString stringWithFormat:@"Current proximity : %d", self.currentProximity]]; 
    [self printLog:[NSString stringWithFormat:@"Previous proximity : %d", self.prevProximity]]; 
    [self printLog:[NSString stringWithFormat:@"Last visited webpage proximity : %d", self.previousProximityTag]]; 

    // Send notification based on the notification enabled flag, proximity and the url found in the response 
    if([self.notificationEnabled isEqualToString:@"true"]) 
    { 


     double days = [self DiffBetweenCurrentAndNotificationDate]; 
     NSLog(@"Days from notification %f",days); 

     NSNumber *notificationDuration =[[NSUserDefaults standardUserDefaults] objectForKey:@"NotificationDuration"]; 
     NSLog(@"Notification duration from plist %f",[notificationDuration doubleValue]); 


     if (days >=[notificationDuration doubleValue] || days == 0) { 

      NSLog(@"Hit count become zero in differeneceBetweenCurrentAndNotificationDate"); 

      hitCount = 0 ; 
     } 

     switch (beacon.proximity) { 

      case CLProximityUnknown: 
       // Do nothing 
       break; 

      case CLProximityImmediate: 
       if(self.url_immediate != nil) 
       { 
         [self sendLocalPushNotification]; 
         self.notificationEnabled = false; 



       } 
       break; 

      case CLProximityNear: 
       if(self.url_near != nil) 
       { 
         [self sendLocalPushNotification]; 
         self.notificationEnabled = false; 


       } 
       break; 

      case CLProximityFar: 
       if(self.url_far != nil) 
       { 
         [self sendLocalPushNotification]; 
         self.notificationEnabled = false; 


       } 
       break; 

      default: 
       break; 
     } 

    } 

    // Open web page based on proximity when general beacons(not notification beacon) detected 
    if([self.status_code isEqualToString:@"200"]) 
    { 
     // Do not open web page while app is in background 
     UIApplicationState appState = [[UIApplication sharedApplication] applicationState]; 
     if((appState != UIApplicationStateBackground) && (appState != UIApplicationStateInactive)) 
     { 
      if (beacon.proximity == CLProximityUnknown) { 
       if(self.currentProximity != self.prevProximity) 
       { 
        self.prevProximity = self.currentProximity; 
       } 

       /* Log */ 
       [self printLog:@"Unknown proximity"]; 
      } 
      else if (beacon.proximity == CLProximityImmediate) { 

       if((self.currentProximity != self.prevProximity) && (![self.current_url isEqualToString:self.url_immediate])) 
       { 
        if(self.currentProximity == self.previousProximityTag) 
        { 
         self.previousProximityTag = self.prevProximity; 

         if(self.flag_immediate == true) 
         { 
          if(navController != NULL) 
          { 
           [self stopTimerTask:self.timer_long]; 
           self.timer_long = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:1] repeats:NO]; 
          } 
          else 
          { 
           [self stopPerformSelectorTask]; 
           [self performSelector:@selector(openWebView:) withObject:self.url_immediate afterDelay:20.0]; 
          } 
         } 
         else 
         { 
          if(navController != NULL) 
          { 
           [self stopTimerTask:self.timer_long]; 
           self.timer_long = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:1] repeats:NO]; 
          } 
          else 
          { 
           [self stopPerformSelectorTask]; 
           [self performSelector:@selector(openWebView:) withObject:self.url_immediate afterDelay:3.0]; 
          } 
         } 
        } 
        else 
        { 
         self.previousProximityTag = self.prevProximity; 

         if(navController != NULL) 
         { 
          [self stopTimerTask:self.timer_short]; 
          self.timer_short = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:1] repeats:NO]; 
         } 
         else 
         { 
          [self performSelector:@selector(openWebView:) withObject:self.url_immediate afterDelay:0.0]; 
         } 
        } 
        self.prevProximity = self.currentProximity; 
       } 
       else if ([self.current_url isEqualToString:self.url_immediate]) 
       { 
        self.prevProximity = self.currentProximity; 
       } 
       /* Log */ 
       [self printLog:@"Immediate"]; 
      } 
      else if (beacon.proximity == CLProximityNear) { 

       if((self.currentProximity != self.prevProximity) && (![self.current_url isEqualToString:self.url_near])) 
       { 
        if(self.currentProximity == self.previousProximityTag) 
        { 
         self.previousProximityTag = self.prevProximity; 

         if(self.flag_near == true) 
         { 
          if(navController != NULL) 
          { 
           [self stopTimerTask:self.timer_long]; 
           self.timer_long = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:2] repeats:NO]; 
          } 
          else 
          { 
           [self stopPerformSelectorTask]; 
           [self performSelector:@selector(openWebView:) withObject:self.url_near afterDelay:20.0]; 
          } 
         } 
         else 
         { 
          if(navController != NULL) 
          { 
           [self stopTimerTask:self.timer_long]; 
           self.timer_long = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:2] repeats:NO]; 
          } 
          else 
          { 
           [self stopPerformSelectorTask]; 
           [self performSelector:@selector(openWebView:) withObject:self.url_near afterDelay:3.0]; 
          } 
         } 
        } 
        else 
        { 
         self.previousProximityTag = self.prevProximity; 

         if(navController != NULL) 
         { 
          [self stopTimerTask:self.timer_short]; 
          self.timer_short = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:2] repeats:NO]; 
         } 
         else 
         { 
          [self performSelector:@selector(openWebView:) withObject:self.url_near afterDelay:0.0]; 
         } 
        } 
        self.prevProximity = self.currentProximity; 
       } 
       else if ([self.current_url isEqualToString:self.url_near]) 
       { 
        self.prevProximity = self.currentProximity; 
       } 
       /* Log */ 
       [self printLog:@"Near"]; 
      } 
      else if (beacon.proximity == CLProximityFar) { 

       if((self.currentProximity != self.prevProximity) && (![self.current_url isEqualToString:self.url_far])) 
       { 
        if(self.currentProximity == self.previousProximityTag) 
        { 
         self.previousProximityTag = self.prevProximity; 

         if(self.flag_far == true) 
         { 
          if(navController != NULL) 
          { 
           [self stopTimerTask:self.timer_long]; 
           self.timer_long = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:3] repeats:NO]; 
          } 
          else 
          { 
           [self stopPerformSelectorTask]; 
          // [self saveFarBeaconProximityMessage]; 

           [self performSelector:@selector(openWebView:) withObject:self.url_far afterDelay:20.0]; 
          } 
         } 
         else 
         { 
          if(navController != NULL) 
          { 
           [self stopTimerTask:self.timer_long]; 
           self.timer_long = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(x:) userInfo:[NSNumber numberWithInt:3] repeats:NO]; 
          } 
          else 
          { 
           [self stopPerformSelectorTask]; 
           // [self saveFarBeaconProximityMessage]; 

           [self performSelector:@selector(openWebView:) withObject:self.url_far afterDelay:3.0]; 
          } 
         } 
        } 
        else 
        { 
         self.previousProximityTag = self.prevProximity; 

         if(navController != NULL) 
         { 
          [self stopTimerTask:self.timer_short]; 
          self.timer_short = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(showAlertOnProximityChange:) userInfo:[NSNumber numberWithInt:3] repeats:NO]; 
         } 
         else 
         { 
          // [self saveFarBeaconProximityMessage]; 

          [self performSelector:@selector(openWebView:) withObject:self.url_far afterDelay:0.0]; 
         } 
        } 
        self.prevProximity = self.currentProximity; 
       } 
       else if ([self.current_url isEqualToString:self.url_far]) 
       { 

        self.prevProximity = self.currentProximity; 
       } 
       /* Log */ 
//     [self saveFarBeaconProximityMessage]; 

       [self printLog:@"Far"]; 
      } 
     } 

    } 

} else { 
    [self printLog:@"Beacon is nil"]; 
    return; 
} 

    } 
    @catch (NSException *exception) { 
//  <#Handle an exception thrown in the @try block#> 
    } 
    @finally { 
//  <#Code that gets executed whether or not an exception is thrown#> 
    } 


} 

, 난 변화 전개 대상으로 시도한 다음 didRangeBeacons 위임 방법은 항상 무 코드로 비컨 배열을 반환한다. 그리고 Array nil 조건을 점검하면, 전체 코드는 objective C에서 try catch로 둘러싸여 있지만 "Beacon array is nil"이라고 말함으로써 응용 프로그램이 충돌하더라도. IOS10은 신호를 지원합니까? 모든 도움을 미리 감사드립니다.

답변

1

일부 사용자는 의 XCode에서 앱 배포 대상을 9.x로 설정하면 문제를 해결할 수 있다고보고 한 iOS 10에서 비콘 탐지 문제에 대한 일화적인 보고서가 많이 있습니다. 자세한 내용은 여기를 참조하십시오 : 답장을

https://stackoverflow.com/a/39641127/1461050

+0

안녕하세요, 감사합니다. 우리는 확인하고 알려 줄 것입니다. – Sakthimuthiah

+0

배포 대상 변경을 시도합니다. 불행히도, 그것의 작동하지 않습니다 – Sakthimuthiah

+0

당신은 이것에 대한 해결책을 찾았습니까? 나는 똑같은 문제를 안고 있습니다. – vivianaranha

관련 문제