我有一个定期拍摄图像的应用程序,我希望在拍摄图像后立即将它们上传到 iCloud 照片流。
似乎需要满足某些条件才能使其起作用。它似乎只在运行 iOS 8 时工作,设备连接到无线,并且通过使用 UIImagePickerController 来拍照(而不是 AVCapture)至少一次。似乎 UIImagePickerController 在出现时会改变一些系统设置,从而允许随后将图像自动上传到 iCloud 照片流。如果我只使用 AVCapture 来拍照,它将无法正常工作。我已确认在 iCloud 设置中启用了“上传到我的照片流”,并且存在活动的无线连接。
这是用于保存从 UIImagePickerController 获取的图像的方法:
- (void)saveImage : (UIImage *)image {
// Add image to the photo library
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest =
[PHAssetChangeRequest creationRequestForAssetFromImage:image];
} completionHandler:^(BOOL success, NSError *error) {
if (!success)
NSLog(@"Error creating asset: %@", error);
}];
}
在装有 iOS 8 的 iPad 上运行时,以下是我在设备系统日志中看到的条目:
Oct 22 21:11:06 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Submitting 1 asset collections for publication.
Oct 22 21:11:06 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
Oct 22 21:11:10 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx uploading 1 assets...
Oct 22 21:11:11 iPad mstreamd[14409] <Notice>: (Note ) PS: Received push notification for invitations topic: com.apple.mediastream.subscription.push userInfo: {
r = xxxxxxxx;
}
Oct 22 21:11:11 iPad mstreamd[14409] <Notice>: (Note ) PS: <MSIOSMediaStreamDaemon: 0x1662ad80>: Push notification received for My Photo Stream with targetPersonID xxxxxxxx.
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x1666fae0>: Plugged in to external power. Allowing file transfers.
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x1666fae0>: Push received. Allowing file transfers to continue for 60.00 seconds
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) PS: MSSubscriber - xxxxxxxx Found 1 new asset collections.
Oct 22 21:11:13 iPad assetsd[11536] <Warning>: Unable to open file to save extended attributes (No such file or directory).
在装有 iOS 9.1 的 iPhone 上运行时,我有类似的日志条目,除了我有关于缓存服务器的其他警告/错误消息以粗体显示:
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Submitting 1 asset collections for publication.
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
**Oct 25 22:35:28 iPhone AssetCacheLocatorService[1658] <Warning>: #df99fdd0 [I:AssetCacheLocatorService.queue] found no caching servers**
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx uploading 1 assets...
**Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Error) mmcs: __mmcs_proxy_locator_exists_block_invoke:167 might have caching server returned with error: Error Domain=NSPOSIXErrorDomain Code=60 "Operation timed out" UserInfo={com.apple.AssetCacheLocator.tag=#1963bd2d, NSLocalizedDescription=quick miss requested}**
**Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...**
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: Received push notification for invitations topic: com.apple.mediastream.subscription.push userInfo: {
r = xxxxxxxx;
}
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: <MSIOSMediaStreamDaemon: 0x157e0c530>: Push notification received for My Photo Stream with targetPersonID xxxxxxxx.
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x157e84410>: Plugged in to external power. Allowing file transfers.
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x157e84410>: Push received. Allowing file transfers to continue for 60.00 seconds
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSSubscriber - xxxxxxxx Found 1 new asset collections.
Oct 25 22:35:30 iPhone assetsd[1624] <Warning>: Unable to open file to save extended attributes (No such file or directory).
在 iOS 9 的这种情况下,当我的应用程序处于活动状态时,图像不会上传,只有在应用程序进入后台时才会上传。
我怀疑问题是由于 1. 某些系统设置仅在 iOS8 中通过 UIImagePickerController 的呈现激活,或者 2. 日志条目所建议的 iOS 9 中缓存服务器的一些问题。
有人知道发生了什么吗?任何想法将不胜感激!谢谢!