How can I get details of likes on iCloud Shared Albums using PhotoKit - cocoa-touch

I've got a PHFetchResult containing the user's iCloud Shared Albums, however I can't find a way to determine whether a photo has been liked by one of the people it is shared with.
I've checked the metadata of the PHAssets that are returned, but the only vaguely related property is favourite, but that only records whether the user has hit the heart button in their own Photos app, not the likes from people who the asset has been shared with.
It looks like this data isn't available - the fact that I can't find anything in the docs suggests this - but I want to ask in case StackOverflow knows better!

I just spent about ten minutes combing the documentation, and running Google searches like this, and couldn't find any way to do this. I would expect this to be fairly easy to find if it existed. I'm 99.9% sure that if this existed I would have found it.
I'd really like to be proven wrong!

I've been on a similar hunt and even finding this question took me a while! I was surprised not more people have sought out this functionality. There's not much literature on this that I could find.
Related question How to Get iCloud Shared Albums Owner Details show the existence of PHCloudSharedAlbum, which I can verify with basic debugging.
let collections = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .albumCloudShared, options: nil)
print("fetchAssetCollections:")
for i in 0..<collections.count {
if collections[i].localizedTitle == "My Test Shared Album" {
print(collections[i])
}
}
Although this type of asset collection exists, it does not appear in the current iOS SDK/API docs as of Xcode 11.4 / iOS 13.4.1 / Swift 5. It seems it's private and not intended for public use.
<PHCloudSharedAlbum: 0x155e2fe30> ED1EB808-33D8-4E71-BD3F-79FCD616A87C/L0/040, title:"My Test Shared Album", subtitle:"(null)" assetCollectionType=1/101
Exact Google searches for "PHCloudSharedAlbum" yield a few GitHub repos with (de-compiled?) source code for Photos.framework, but even the fields in there are very limited.
short _cloudAlbumSubtype;
bool _cloudMultipleContributorsEnabled;
NSNumber * _cloudOwnerEmailKey;
NSString * _cloudOwnerFirstName;
NSString * _cloudOwnerFullName;
NSString * _cloudOwnerLastName;
bool _owned;
Incidental public facing Apple doc, If Shared Albums aren't working, implies (by my interpretation) that this social information is not directly tied to assets in iCloud photo collections.
Any comments or likes attached to a photo or video in a shared album aren't saved with the photo or video.
Or at least, if that information is tied to photos and videos, it's not exposed. It does not seem available to users exporting iCloud shared photo albums or to developers.

Related

Reaching iCloud thumbnail dictionary

I am trying to update thumbnail image for file in iCloud drive.
I have already read old answers about this, people are suggesting to use NSFileCoordinator and etc. but essentially you have to access thumbnail dictionary with NSURLThumbnailDictionaryKey with this method:
- (BOOL)getResourceValue:(out id _Nullable * _Nonnull)value forKey:(NSURLResourceKey)key error:(out NSError ** _Nullable)error
and then change value for NSThumbnail1024x1024SizeKey.
But apple documentation says:
This method applies only to URLs that represent file system resources.
Is there a way to access iCloud drive files via URL and update the thumbnail?
Following link from Apple documentation provides clear solution for iOS (scroll down till iCloud Document Thumbnails): Apple documentation link also there is steps for macOS using Quick Look.
Has anyone done something similar? the Quick Look documentation is so unclear with this simple step to update thumbnail in iCloud.

PHAsset - Property way to save captured PHAssets locally? (in app)

trying to understand the concept for Photos/Photos.h framework.
my goal is:
write captured video url (or asset) to app's "userDefaults".
read from "userDefaults", & fetch each saved asset data (thumbnail & url)
Since you're not providing any code (nor asking for any), I can help sort some of this out for you -- but you need to study a bit more before you can put it all together. Especially if you think you've asked a question which has one simple correct answer.
UserDefaults is not a good place to store an image. Images are big. (You should look at Apple's documentation of what UserDefaults is for/how it's intended use).
UserDefaults
There's more than one place to store images. Do you want the system to delete them if you start running out of memory? Then it belongs in cache:
let cachesPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).last!
Do you want to depend on it being around the next time the app is run? There is a standard place for that as well:
let userDocumentsFolder = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
Do you want iTunes to back up the images for you automatically? It expects files to be in a certain place for automatic backup. Do you have a way to keep track of where it is (the path to the file can change if the app is re-run). For that you might require persistent storage, so CoreData or Realm might be an option for you. Or you could scan your directory and create a list of files you've already saved. Then you'll need a way to select the correct one. (What did you call it? Should the user select it?)
Apple has very clearly written and useful documentation on access to the Photos library and using PHAssets. Here's just one example:
PHAsset - Photos
There are a lot of talented people on this site, and they are willing to help you, but you need to do your homework before coming here.
I recommend you read these linked documents, start writing some code, and if you run into problems please come back and ask any specific question you have about any specific problem you've encountered. Include the code which causes the problem, as well as the exact error message you are getting. We will be glad to help.

Get GPS location from MLMediaObject on OS X

I'm getting started with the Media Library Framework on OS X, specifically with regard to accessing a user's Photos library. After a lot of wrangling I was able to get access to each photo as a MLMediaObject, but now I've hit a roadblock:
How can I access the GPS location of the photo, from the MLMediaObject?
This sort of information is easy to get from the old ALAssetsLibrary system, or from the Photos Framework on iOS, using a CLLocation property associated with the media object, but I can't seem to figure it out with the Media Library Framework. The documentation lists these as the only properties of the MLMediaObject:
attributes
mediaType
contentType
name
URL
originalURL
fileSize
modificationDate
thumbnailURL
artworkImage
At first I thought attributes looked promising, but as far as I can tell there are a very small number of options for that property, and none of them are related to the location.
Then I thought, if I have the file's URL, I ought to be able to get the GPS info directly from the file, but that is proving much more difficult than I expected.
Is there an established means of getting the CLLocation, or other form of GPS data, from a photo using the MLMediaObject? Or if not, can anyone think of a more roundabout way of getting access to that information, starting from an MLMediaObject?
In my case I have keys latitude and longitude in attributes. So I assume that it's GPS location of the photo.

Retrieving and viewing google docs using gdata in objective-c

I've been trying to find an answer for this for a while and I have not come across something that explains whether it is possible or not:
I have a bunch of documents in Google Docs and I'm retrieving the list of them using gdata library. I have tried a bunch of different ways to display/open just a single one when I select one from the list but I have not been able to find what kind of request to do or url to send with the request.
The files are public and the share settings are set to public but they won't show up.
Can anyone help me out figure out how to open a Google Docs document (any file format) either in an UIWebView or in the native app?
EDIT Ok, I think there was a bit of confusion as to this question. I have a list of documents from a user's feed in which I store the resourceID of the documents in my database. These documents are public and therefore should be allowed to be opened and viewed by others. Say another user comes in and wants to view documents from another person. I call the resourceID into the viewer url and it still says it needs authorization. I figured, since the document is public, a user that has not logged in (therefore no auth token) should be able to view the document still. Just like google docs works?
The DocsSampleWindowController included with the Objective-C library includes a method that shows how to open a document using its HTML link:
- (IBAction)viewSelectedDocClicked:(id)sender {
NSURL *docURL = [[[self selectedDoc] HTMLLink] URL];
if (docURL) {
[[NSWorkspace sharedWorkspace] openURL:docURL];
}
}
I have no idea about Objective-C but I can tell you in general terms..
Just send an authenticated request at the below uri:
Be sure to replace YourDocument'sResourceID with the resource ID of the document that you want to read..
https://docs.google.com/feeds/download/documents/export/Export?id=**YourDocument'sResourceID**&exportFormat=txt&format=txt
you can also play with the variable format in the above uri.. txt gives you the simple text and no styles..

Graph API not returning image/picture for community pages

Graph API is not returning image("picture" attribute) for objects corresponding to community pages, which used to be returned earlier. For example this https://graph.facebook.com/178790412179919 does not have picture attribute whereas the corresponding page has an image.
Also the FQL query done on the "albums" connection for some objects does not have a "cover_pid" attribute for an album corresponding to type "profile", which again used to work earlier.
Does anybody know if anything has changed in Graph API corresponding to this in last couple of weeks (I am fairly confident it used to work earlier in the expected way). I looked through Facebook API release notes but could not find any changes corresponding to this. Please let me know if this not appropriate post for this forum.
https://developers.facebook.com/docs/reference/api/page/
picture is a connection, not an attribute. So ...
https://graph.facebook.com/178790412179919/picture
And as the docs say: Returns a HTTP 302 with the URL of the user's profile picture.
Kinda goofy? Yes, but it works exactly as the docs say it does. I suspect they implemented it this way so it could easily be used in an <IMG> tag.
UPDATE:
It still works via FQL. In your case:
https://api.facebook.com/method/fql.query?query=SELECT+page_id%2C+pic+FROM+page+WHERE+page_id+%3D+178790412179919&format=json
I can confirm that this PREVIOUSLY worked, but NO LONGER works. Facebook have removed the picture connection from Community Pages.
I suspect the reason is that most of these images are pulled from Wikipedia, and there was a licensing / attribution issue.
Unfortunately, Facebook is no longer a reliable source of images for entities (e.g. bands).