0

Trying to use the following code when PhPhoto status is PHAuthorizationStatusLimited

PHAuthorizationStatus prevStatus = [PHPhotoLibrary authorizationStatus];
if (prevStatus == PHAuthorizationStatusLimited)
        {
            [PHPhotoLibrary requestAuthorizationForAccessLevel:(PHAccessLevelReadWrite) handler:^(PHAuthorizationStatus status) {
                if (status == PHAuthorizationStatusLimited) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [PHPhotoLibrary presentLimitedLibraryPickerFromViewController:self];
                    });
                }
            }];

I get No known class method for selector 'presentLimitedLibraryPickerFromViewController: [PHPhotoLibrary presentLimitedLibraryPickerFromViewController:self];

I need to show the user the limited library to select photos. Are there any other options at this specific state? What am i missing?

stefanosn
  • 3,264
  • 10
  • 53
  • 79
  • Found it. You need to add Photos and import frameworks in your project. Then call [[PHPhotoLibrary sharedPhotoLibrary] presentLimitedLibraryPickerFromViewController:self]; – stefanosn Feb 08 '22 at 22:27
  • Now i get Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHPhotoLibrary presentLimitedLibraryPickerFromViewController:] any ideas why? – stefanosn Feb 08 '22 at 22:34

1 Answers1

0

You need to init viewController that handles the display before =>

UIViewController *presentedViewController = RCTPresentedViewController();
[[PHPhotoLibrary sharedPhotoLibrary] presentLimitedLibraryPickerFromViewController:presentedViewController];
Idriss Sakhi
  • 267
  • 2
  • 5