Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlutterPhotokit.saveToCameraRoll and saveToAlbum crash the app #3

Open
rogiervandenberg opened this issue Oct 24, 2018 · 4 comments
Open

Comments

@rogiervandenberg
Copy link

When running your example on my iPhone simulator (iPhone XS Max • 6F9DE665-62D8-4DCC-A47B-CA97DAF9BD01 • ios • iOS 12.0 (simulator)) it crashes:

Reproduce with the code example

git clone [email protected]:kmorkos/flutter_photokit.git
cd flutter_photokit/example
flutter run -d 'iPhone XS Max'

When clicking the 'save to camera roll' button, it crashes. From within my own project I found out that it crashes on the line of FlutterPhotokit.saveToCameraRoll. But I cannot get any further feedback unfortunately, because of Lost connection to device. Exited (sigterm).

My setup

[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.13.6 17G65, locale en-NL)
    • Flutter version 0.9.4 at /Users/rogier/DEV/flutter
    • Framework revision f37c235c32 (4 weeks ago), 2018-09-25 17:45:40 -0400
    • Engine revision 74625aed32
    • Dart version 2.1.0-dev.5.0.flutter-a2eb050044

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/rogier/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 27.0.3
    • ANDROID_HOME = /Users/rogier/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 29.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.28.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.19.0

[✓] Connected devices (2 available)
    • G8231         • QV700E8M0K                           • android-arm64 • Android 8.0.0 (API 26)
    • iPhone XS Max • 6F9DE665-62D8-4DCC-A47B-CA97DAF9BD01 • ios           • iOS 12.0 (simulator)

• No issues found!
@rogiervandenberg
Copy link
Author

I just found out through XCode: "This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data."

Solution is to change the NSPhotoLibraryAddUsageDescription value in the Info.plist into NSPhotoLibraryUsageDescription.

#4

@kmorkos
Copy link
Owner

kmorkos commented Oct 24, 2018

That's strange, according to the docs:

NSPhotoLibraryAddUsageDescription (String - iOS) This key lets you describe the reason your app seeks write-only access to the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

NSPhotoLibraryUsageDescription (String - iOS) This key lets you describe the reason your app accesses the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

Although this keys governs read and write access to the user’s photo library, it’s best to use NSPhotoLibraryAddUsageDescription if your app needs only to add assets to the library and does not need to read any assets.

This plugin never accesses the photo library, just writes to it which is why I used NSPhotoLibraryAddUsageDescription (this worked when I tested with iOS 11). I unfortunately do not have access to a Mac to test with anymore, so I can't test behavior on iOS 12.

@tyl0r
Copy link

tyl0r commented Apr 15, 2019

I can confirm that my app crashes when I only have NSPhotoLibraryAddUsageDescription in my Info.plist file. Changing to NSPhotoLibraryUsageDescription fixed the issue for me. I'm on iOS 12.2 and MacOS 10.14.4 using Android Studio.

In my case I need read access to the library as well, not just write access.

@danieleformichelli
Copy link

Same problem here.
NSPhotoLibraryUsageDescription should not be required to add image to the gallery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants