Is there maximum file or image size for twitter or Facebook via UIActivityViewController?

ⅰ亾dé卋堺 提交于 2019-12-24 05:35:22

问题


I use UIActivityViewController to share images and text to Message, Email, Facebook, Twitter etc. Until recently, I thought I could send images of any size (at least up to 5MB). However, I have noticed that I can no longer send images greater than say 2.5MB to Facebook or twitter. E.g., I select an image to share, open the activityViewController and select Facebook. The activityViewController slowly opens the Facebook interface/view (but doesn't show attached image) then closes the Facebook view (and implicitly the activityviewcontroller). The app itself doesn't crash as I can reselect the image and send it via Message or email. I've been working on the app for months and don't think it was happening when I was testing a few weeks ago. I don't have any problems sharing smaller images to Facebook or twitter. I'm wondering if anyone else is having the same problem and whether this is a known limitation of UIActivityViewController.

Update:

I filed a technical report and got the following information: Facebook and Twitter are implemented as system-proved share extensions. All extensions have a memory limit placed on them. This can cause the extension to be terminated but my app keeps going as it is run in a separate process. This can be seen using the device console crash reports (not Xcode debug console or crash reports in ~/Library/Logs/CrashReporter/ ). The device console shows warnings such as "ShareExtension[4959] : Received memory warning”.

Apparently Facebook and Twitter etc impose the limits on the service and I was advised to contact them for more information. Apple does downsize images to comply with limits. This worked seemed to work for sharing a single file rather than multiple large images (when I tested it by sharing multiple files by Mail, the first image was resized but not later images). Strangely, I can now share a single large file to Facebook/Twitter but not multiple large files. The memory allocation is very large once you have selected Facebook as the extension (jumps from 12MB prior to selection to >100MB) for a ~4MB photo.

Apple recommended that I use URLs to the images rather than UIImage objects to more efficiently handle larger images. This hasn't fixed my problem so I'm going to try to use UIActivityItemProvider to limit file sizes for all activities except Saving and Printing ....

来源:https://stackoverflow.com/questions/31135230/is-there-maximum-file-or-image-size-for-twitter-or-facebook-via-uiactivityviewco

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!