| 测试已测试 | ✗ |
| 语言语言 | SwiftSwift |
| 许可证 | MIT |
| 发布最后发布 | 2018年3月 |
| SPM支持 SPM | ✗ |
由Antony Harfield,Thanakorn Amnuaywiboolpol维护。
| 依赖 | |
| Firebase/Core | >= 0 |
| Firebase/Storage | >= 0 |
FIRStorage for iOS 带缓存和离线功能
克隆/下载 FirebaseOfflineAppDemo 并在 Xcode 中按下播放前运行 pod install。示例包含 3 个示例:无缓存,NSCache 和 FirebaseStorageCache。
此项目假定您已经为 iOS 设置了 Firebase。
FirebaseStorageCache 通过 CocoaPods 提供。要安装,只需将以下行添加到 Podfile 中
pod 'FirebaseStorageCache'let ref: FIRStorageReference = ...
FirebaseStorageCache.main.get(storageReference: ref) { data in
// do something with your file
}let oneWeekDiskCache = DiskCache(name: "customCache", cacheDuration: 60 * 60 * 24 * 7)
let firStorageCache = FirebaseStorageCache(cache: oneWeekDiskCache)
firStorageCache.get(storageReference: ref) { data in
// do something with your file
}imageView.setImage(storageReference: ref)简单
webView.loadHTML(storageReference: ref)在 HTML 上进行后处理
let styleHTML: (Data) -> Data = { data in
let pre = "<style>body {margin: 16px}</style>"
var preData = pre.data(using: .utf8) ?? Data()
preData.append(data)
return preData
}
webView.loadHTML(storageReference: ref, postProcess: styleHTML)在你的 AppDelegate 的 didFinishLaunchingWithOptions 中,你应该调用你磁盘缓存的 prune()
方法以删除任何旧文件
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
FirebaseStorageCache.main.prune()
return true
}Antony Harfield,[email protected]
FirebaseStorageCache 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。