CKShare thumbnail

If I share via Message, all thumbnails are ok.


If I share via email and if the user clicks on the link, he is redirected to iCloud.com, which is great.

The problem is that the iCloud.com page doesn't show the correct thumbnail. It should the standard one (when no icon is setup).

Is there a way to setup the correct one?


When I create the share I set the share like this but obviously it's not working:

if let appIconImage = UIImage(named: "Thumbnail"), let appIconData = UIImagePNGRepresentation(appIconImage) { 
    share[CKShareThumbnailImageDataKey] = String(data: appIconData, encoding: .utf8) as CKRecordValue? 
}

Replies

I could be wrong here but worth a shot: I think you need to implement the itemThumbnailData(for csc: UICloudSharingController) -> Data? delegate method (of the UICloudSharingControllerDelegate protocol) in whichever controller you are performing the sharing.


Then in this method you need to convert the UIImage to Data. Finally, return the data object. I believe this is the code (Swift 3):


func itemThumbnailData(for csc: UICloudSharingController) -> Data? {
  let image = UIImage(named: "myImage")
  return image?.pngRepresentationData
}


Does this work?

I think that if the user is redirected to iCloud.com, there it will see the App icon, no the share thumbnail.


If there is no icom for the app yet in itunes connect then it will show the standard one (when no icon is setup).


If you open Safary in Mac and go to the Share Url


Develop > Show Error Console > Warnings


You will see:


CloudOS: No app icon found in App Store associated to container iCloud.com.YourCompany.YourAppName.


func itemThumbnailData(for csc: UICloudSharingController) -> Data?


It is to get the image in the App, no in iCloud.com