2014-04-07 2 views
0

iOS 7 용 앱을 개발 중이며 사용자 위치를 찾은 다음 다른 사용자가 같은 위치에 있는지 확인해야합니다. 사용자가 앱을 열고 모든 항목을 자주 업데이트하고 같은 위치에 사용자를 표시하는 즉시 업데이트해야합니다. 사용 가능한 예제를 살펴 봤지만 Parse를 사용하는 것으로는 충분하지 않은 것 같습니다. 아무도 나에게이 일을하는 법에 대한 도움을 줄 수 없거나, 내가 뭘하려고하는 것과 비슷한 몇 가지 예를 아는 사람이라면 크게 감사 할 것입니다. 미리 감사드립니다!iOS 7 Parse Geolocation

답변

0

당신은 여러 조각을 아래로 문제를 휴식하고 해결하기 위해 필요 - 응용 프로그램이 열리고 주기적으로 Location and Maps programming guide 좋은 출발점이 될 것입니다 때

  1. 에서 사용자의 위치를 ​​얻습니다. CLLocationManager를 사용하여 초기 위치를 얻을 수 있으며 중요한 위치 변경 이벤트에 등록하여 앱이 실행 중이 아닌 경우에도 주기적으로 업데이트를받을 수 있습니다. Apple에는 예제 코드가 있습니다. 거기에 다른 예제가 많이 있습니다. "핵심 위치 예제"를 사용하여 검색하십시오.
  2. 사용자의 위치를 ​​Parse 데이터베이스에 저장합니다. Parse.com에 예제와 설명서가 있습니다. 앱이 동일한 위치에있는 다른 사용자를 위해 데이터베이스를 쿼리 할 수있게 해주는 웹 서비스를 제공 할 수도 있습니다. 앱이 실행되지 않을 때 같은 위치에있는 다른 사용자 식별 구문 분석 작업을 사용하여 데이터베이스를 트롤링 할 수 있습니다 사용자 위치를 일치시키고 사용자에게 푸시 알림을 보냅니다. 다시 Parse.com에 배경 작업 및 푸시 알림을 설정하는 방법을 보여주는 예가 있습니다.
+0

고마워요! 구문 분석 백그라운드 작업에 대한 설명서를 찾을 수있었습니다. 나는 그것을 시도 할 것이다. –

0

이것은 현재 위치를 얻고 현재 구문 분석을 저장하는 데 도움이 될 수 있습니다.

func locationManager(manager: CLLocationManager!, didUpdateLocations 
locations: [AnyObject]!) { 

    var userLocation : CLLocation = locations[0] as! CLLocation 

    var latitude = userLocation.coordinate.latitude 
    var longitude = userLocation.coordinate.longitude 

    var latDelta : CLLocationDegrees = 0.01 
    var lonDelta : CLLocationDegrees = 0.01 

    var span : MKCoordinateSpan = MKCoordinateSpanMake(latDelta, 
    lonDelta) 

    var location : CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude) 
    var region : MKCoordinateRegion = MKCoordinateRegionMake(location, span) 

    self.mapView.setRegion(region, animated: true) 

    let testObject = PFObject(className: "User") 

    let currentPoints = PFGeoPoint(latitude: latitude, longitude: longitude) 

    testObject.setValue(currentPoints, forKey: "currentLocation") 

    testObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in 

     if (success) { 

      dispatch_async(dispatch_get_main_queue()) { 

       println("added to parse") 
      } 


     } else { 

      println(error) 

     } 

    } 

}