mcf*_*oft 3 iphone ios icloud swift
我在 Applestore 发布了我的应用程序以供审核,但遭到拒绝,上面写着:
" 在启动和内容下载时,您的应用程序会在用户的 iCloud 上存储 1.4 GB,这不符合 iOS 数据存储指南。"
我在问题的末尾粘贴了完整的拒绝文本。
我不知道将数据存储到 ICLoud,我不确定他们如何测试我的应用程序。他们建议查看 iCloud 存储的设置,我做了什么,但是在安装时我看不到我的应用程序使用的任何 iCloud 存储:
经过一段时间或设置后,是否有任何自动过程将数据从文档文件夹存储到云端?
通常我的应用程序是 - 从我的服务器下载一个 zipfile 以存储在我的应用程序的 Document 文件夹中。- 然后应用程序也在文档文件夹中解压缩 zipfile。
使用 IOS-Simulator 进行测试时,我可以使用外壳检查文档文件夹的内容,内容就在那里。(而不是在 iCloud 上)
有人可以帮助我,在这种情况下开发人员必须做什么。
我在这里粘贴了相关代码,它显示了我如何下载内容以及如何解压缩内容。
class ViewController: UIViewController, NSURLSessionDelegate {
let sDataPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString as String; ///var/mobile/Containers/Data/Application/8897ED62-5BAE-4255-8459-F0F8381C171F/Documents/
download_file(sfrom,sToLocation: sDataPath);
func download_file(sURL: String, sToLocation: String) {
print("start downloading ...");
print("sURL : " + sURL + " sToLocation : " + sToLocation);
bytesDownloaded=0;
let downloadsessiondelegate = self;
downloadsessiondelegate.storePath=sToLocation;
downloadsessiondelegate.progressView=progressView;
downloadsessiondelegate.surl=sURL;
struct SessionProperties {
static let identifier : String! = "url_session_background_download"
}
let date = NSDate()
let calendar = NSCalendar.currentCalendar()
let components = calendar.components([.Hour, .Minute], fromDate: date)
let hour = String(components.hour)
let minutes = String(components.minute)
let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("session_" + hour + minutes)
let backgroundSession = NSURLSession(configuration: configuration, delegate: downloadsessiondelegate, delegateQueue: nil)
//myURLSession = NSURLSession(configuration: configuration, delegate: delegate, delegateQueue: nil)
let url = NSURLRequest(URL: NSURL(string: sURL)!)
//var downloadTask = backgroundSession.downloadTaskWithRequest(url)
let downloadTask = backgroundSession.downloadTaskWithRequest(url)
downloadTask.resume()
}
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location1: NSURL) {
//println("session \(session) has finished the download task \(downloadTask) of URL \(location1).")
// remove Session ID
//defaults.removeObjectForKey(<#defaultName: String#>)
let defaults = NSUserDefaults.standardUserDefaults()
defaults.removeObjectForKey("SessionProperties_identifier" + "_" + surl)
var error: NSError?
let target=storePath;
var source : String = location1.absoluteString;
let filemgr = NSFileManager.defaultManager();
let modifiedsource = source.stringByReplacingOccurrencesOfString("file://", withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil)
if (filemgr.fileExistsAtPath(target))
{
do {
try filemgr.removeItemAtPath(target)
} catch let error1 as NSError {
error = error1
}
//println("FILE AVAILABLE");
}
do {
try filemgr.moveItemAtPath(modifiedsource, toPath: target)
dispatch_async(dispatch_get_main_queue(),{
self.progressView.setProgress(0, animated: false);
//progressView.removeFromSuperview();
print("Move successful")
self.install_content();
})
//download_file_finished();
} catch var error1 as NSError {
error = error1
print("Moved failed with error: \(error!.localizedDescription)")
install_failed("Moved failed with error: \(error!.localizedDescription)");
}
}
func unzipFile(sZipFile: String, toDest: String, estimatedByte:Int){
SSZipArchive.unzipFileAtPath(sZipFile, toDestination: toDest, progressHandler: {
(entry, zipInfo, readByte, totalByte) -> Void in
//let itotalByte=totalByte;
let stufe=4096*1000;
if totalByte % stufe == 0 {
//println("readByte : \(totalByte)")
}
dispatch_async(dispatch_get_main_queue()) {
var percent:Float=Float(Float(totalByte)/Float(estimatedByte));
if percent>1.0{
percent=1.0;
}
let percent_int=Int(percent*100);
let percenttext:String=String(percent_int);
self.progressView.setProgress(percent, animated: false);
let sMessage=self.actualinstalldefinition.title;
let messagewithprozent=sMessage + " (" + percenttext + "%)";
self.progress_label_Titel.text = messagewithprozent;
if percent_int % 20 == 0 && self.lastpercent != percent_int{
let progressimage=self.get_random_progress_image();
self.progressImageView.image = progressimage;
self.lastpercent=percent_int;
}
}
}, completionHandler: { (path, success, error) -> Void in
if success {
// Loesche das ZipFile
let fileManager = NSFileManager.defaultManager()
var error: NSError?
if (fileManager.fileExistsAtPath(sZipFile)){
do {
try fileManager.removeItemAtPath(sZipFile)
} catch let error1 as NSError {
error = error1
} catch {
fatalError()
}
}
dispatch_async(dispatch_get_main_queue(),{
self.progressView.setProgress(0, animated: false);
//progressView.removeFromSuperview();
print("Move successful")
self.install_content();
})
} else {
//progressBar?.hidden = true
self.install_failed(error.localizedDescription);
print(error)
}
})
}
Run Code Online (Sandbox Code Playgroud)
完整的拒绝声明:
2.23 - Apps must follow the iOS Data Storage Guidelines or they will be rejected
Run Code Online (Sandbox Code Playgroud)
2.23 详情
在启动和内容下载时,您的应用程序会在用户的 iCloud 上存储 1.4 GB,这不符合 iOS 数据存储指南。
下一步
请确认仅用户使用您的应用程序创建的内容(例如文档、新文件、编辑等)按照 iOS 数据存储指南的要求由 iCloud 进行备份。此外,请检查您的应用程序使用的任何临时文件是否仅存储在 /tmp 目录中;当确定不再需要这些文件时,请记住删除或删除存储在此位置的文件。
可以重新创建但必须保留以保证应用程序正常运行的数据 - 或者因为用户希望它可用于离线使用 - 应标记为“不备份”属性。对于 NSURL 对象,添加 NSURLIsExcludedFromBackupKey 属性以防止备份对应的文件。对于 CFURLRef 对象,使用相应的 kCRUFLIsExcludedFromBackupKey 属性。
资源
要检查您的应用程序存储了多少数据:
- Install and launch your app
- Go to Settings > iCloud > Storage > Manage Storage
- Select your device
- If necessary, tap "Show all apps"
- Check your app's storage
Run Code Online (Sandbox Code Playgroud)
有关阻止文件备份到 iCloud 和 iTunes 的更多信息,请参阅技术问答 1719:如何阻止文件备份到 iCloud 和 iTunes。
如果您难以重现报告的问题,请尝试测试技术问答 QA1764:如何重现针对 App Store 提交报告的错误中描述的工作流程。
如果您在使用上述资源后遇到代码级问题,不妨咨询 Apple 开发者技术支持。当 DTS 工程师跟进您时,请准备好提供: - 拒绝问题的完整详细信息 - 屏幕截图 - 重现问题的步骤 - 符号化崩溃日志 - 如果您的问题导致崩溃日志
放置在 Documents 文件夹中的文件会自动备份到 iCloud。
备份过程可能不会立即开始,这就是您看不到应用程序的 iCloud 存储空间的原因。
使用此代码从自动备份中排除文件。
try! filePath.setResourceValue(true, forKey: NSURLIsExcludedFromBackupKey)
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅文档。
| 归档时间: |
|
| 查看次数: |
1620 次 |
| 最近记录: |