2017-12-22 43 views
0

이미지 및 PDF 파일을 내 보관 용 계정에 업로드하는 데 DropboxSwiftApi을 사용하고 있습니다. 인터넷에 연결되어 있지 않아도 이미지와 PDF를 선택할 수 있기를 원할 때 자동으로 업로드됩니다. 인터넷이 가능합니다. 어떤 접근 방식이 이것을 달성하는 것이 더 좋을까요? 백그라운드 업로드 같은 것이 있습니까? 이 데이터를 일부 pool_list에 추가하여 인터넷을 사용할 수 있도록 업로드 할 수 있습니까? 도와주세요. 감사.백그라운드에서 이미지 업로드

답변

0

Reachability.swift을 사용하여 인터넷 연결을 관찰 할 수 있습니다. 인터넷이 인터넷에 연결하면 인터넷을 사용할 수있는 경우이 방법이 호출됩니다

//declare this property where it won't go out of scope relative to your listener 
let reachability = Reachability()! 

    //declare this inside of viewWillAppear 

     NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(_:)), name: .reachabilityChanged, object: reachability) 
     do{ 
      try reachability.startNotifier() 
     }catch{ 
      print("could not start reachability notifier") 
     } 

서버에 모든 데이터를 업로드 할 수 있습니다 당신이 일시적으로 즉시 데이터베이스에 데이터를 저장할 수 있습니다 사용할 수없는 경우

func reachabilityChanged(note: Notification) { 

    let reachability = note.object as! Reachability 

    switch reachability.connection { 
    case .wifi: 
     print("Reachable via WiFi") 
    case .cellular: 
     print("Reachable via Cellular") 
    case .none: 
    print("Network not reachable") 
    } 
} 

호프가 문제를 해결할 수 있기를 바랍니다.