Voon Sze Ching
Voon Sze Ching

Reputation: 69

Request photolibrary permission on ios causing watchos to crash?

OS: IOS 10 and watchos3

I noticed an issue when developing my latest app.

My app needs to request for photolibrary permission to save some images. In both watch app and ios, I have added the photo library access permission in the plist.

I noticed that when I press request permission on my ios device when the watch app is running on foreground.

Privacy - Photo Library Usage Description

Once the ios permission request is successful, the watch app will crash, with the following code Program ended with exit code: 0, which seems like os level behavior to me.

    
    func requestPhotoLibraryPermission(){
        PHPhotoLibrary.requestAuthorization { status in
            switch status {
            case .authorized:
                
                break
            default:
                self.showErrorMessage(title: NSLocalizedString("Permission Denied", comment: "Permission Denied"), message:  NSLocalizedString("You can enable Photo Library permission from the settings app", comment: "You can enable Photo Library permission from the settings app") ,completionBlock: {
                })
                // place for .NotDetermined - in this callback status is already determined so should never get here
                break
            }
            
        }
        
    }

As you can see, the code is very straight forward. Anyone experience similar issue? Is there any known workaround?

Upvotes: 3

Views: 183

Answers (2)

Voon Sze Ching
Voon Sze Ching

Reputation: 69

Tested with a brand new project, same issue , I believe iOS inform watchos to restart the app when permission changes.

Same behavior when you change your app permissions at iOS setting page and go back to your app.

Upvotes: 2

immadbananas
immadbananas

Reputation: 309

Forgive me if I misunderstood, but did you add the key: "Privacy - Photo Library Usage Description" and usage description for the key value to your plist?

Upvotes: -1

Related Questions