내 앱에서 오디오를 녹음 한 다음 결과 오디오 파일을 리소스 (그리고 현재 날짜와 시간을 제목으로 사용)로 ENNote를 만들고이 노트를 Evernote에 업로드합니다. 업로드가 완료되면 사용자에게 이미 알림이 전송됩니다. 이제 업로드 진행 상황을 보여 드리고자합니다. 그 제외 progressHandler는를 호출되지 않습니다,Evernote : 메모의 업로드 진행 상태를 확인하려면 어떻게해야합니까?
ENSession.shared.upload(note, policy: .create, to: nil, orReplace: nil, progress: progressHandler, completion: completionHandler)
모든 작품 : 그래서이 기능을 사용하고 있습니다. 나는 에버 노트 SDK를 검색하고 여러 장소에서 이러한 종류의 코드를 발견
#if EN_PROGRESS_HANDLERS_ENABLED
if (context.progress) {
context.noteStore.uploadProgressHandler = context.progress;
}
#endif
이 함께 할 수있는 뭔가가 보인다. 하지만이 #if ... #endif 구문에 익숙하지 않다는 것을 말해야합니다. 샘플 프로젝트를 검색하여 EN_PROGRESS_HANDLERS_ENABLED 값이 실제로 설정된 장소를 찾을 수 없습니다.
progressHandler는 진행 시간이 오래 걸릴 때만 호출되므로 몇 분 (4MB) 동안 녹화하고 해당 녹음을 업로드한다고 생각했습니다. 업로드 시간이 상당히 오래 걸렸지 만 진행 과정이 여전히 불리지 않았습니다.
나는 꽤 오랫동안 인터넷을 검색했지만 운이 없었다. 진행률 처리기가 호출되지 않는 이유는 무엇입니까? ENNote의 업로드 진행 상황을 어떻게 확인할 수 있습니까? 여기
내 코드의 관련 부분은 다음과 같습니다
private func sendToEvernote() {
let progressHandler: ENSessionProgressHandler = { progress in
self.progressView.progress = Float(progress)
self.progressView.alpha = 1
print("Progress:", progress) // Never gets printed
}
let completionHandler: ENSessionUploadNoteCompletionHandler = { (noteRef, error) in
if let error = error { print(error.localizedDescription) }
self.noteRef = noteRef
self.progressView.alpha = 0
self.showBanner(text: "Upload complete. Tap here to open in Evernote.")
}
do {
let note = ENNote()
let title = titleFromCurrentDate()
let filename = title + ".m4a"
note.title = title
let data = try Data(contentsOf: audioURL)
guard let resource = ENResource(data: data, mimeType: "audio/mp4a-latm", filename: filename)
else {
alert(title: "Export failed", message: "Audio file could not be attached to note.")
return
}
note.add(resource)
ENSession.shared.upload(note, policy: .create, to: nil, orReplace: nil, progress: progressHandler, completion: completionHandler)
} catch {
alert(title: "Export failed", message: "Audio file could not be converted to Data type.")
}
}
더 완벽한 해결책을 게시 해 주셔서 감사합니다. –