Search code examples
xcode5ios8camera-rollalassetlibrary

ios 8, how to get all photos using ALAssetLibrary to replace the missing camera roll album


I have an app that has a custom Image Picker that uses the ALAssetLibrary to create an Album picker and image picker. We've implemented a custom picker in order for our customers to select multiple images. This image picker works great under iOS 7 and shows the "Camera Roll" album with ALL the user's photos. However, when running the same app under iOS 8, it seems that Apple has removed the "Camera Roll" album from the Albums view and only shows "Recent Photos". From what I can see, the only way to access all photos in iOS 8 is through the Collection view (in the Photos app or the new built-in picker). Unfortunately, I can't use Photokit at this time because I still need to support my iOS 6 & 7 users. Does anyone know of a way to obtain all the assets and create a custom camera roll album using the ALAssetLibrary when running an iOS 7 app under iOS 8 (compiled in Xcode 5)?

UPDATE

Well, as I stated in my original post above, I was not initially able to use the new Photos Framework (PhotoKit). However, we recently moved our builds to Xcode 6 and I can now use the photos framework to create a group of all photos (look at the WWDC ExampleappusingPhotosframework sample code for how to do this).

However, as powerful as everyone is saying PhotoKit is, it's missing some crucial filtering capabilities. In fact there is no easy way to filter out photos in the original "PhotoStream" using a predicate with PHFetchResult. You can only use the public properites. Fortunately, I figured out how to filter them using the PHAsset description. The assetSource key listed in the description is equal to 2 if the photo is in the user's photostream. So, I used fast enumeration on the results and moved all the assets to an array that were not in the PhotoStream using a simple stringInRange filter on the asset.description property (looking for "assetSource=2"). It may not be the best solution, but it works for now so a user does not see duplicates of their photos from both the local library and their photostream. At least I can present all the customer's photos and allow my multi media picker to function as close as the original class that used the ALAssetLibrary.

By all mean, if someone has a better solution using a predicate, please lmk.


Solution

  • Alright, so seems like it was just a bug, and iOS 8.0.2 fixed it (at least for me, as I can now see all the photos in the image picker).

    This release contains improvements and bug fixes, including:

    [...] Fixes an issue that prevented some apps from accessing photos from the Photo Library. [...]