Ionic 3相机插件在iPhone上使用saveToPhotoAlbum true崩溃

时间:2018-11-30 07:12:16

标签: ionic-framework camera ionic3 ionic-native

我正在与Ionic 3配合使用,并且试图将照片直接保存到图库中。

它在Android上运行良好,但在iPhone上崩溃,当我将saveToPhotoAlbum设置为false时,它运行良好,所以我意识到问题出在此选项上。

我正在使用文档代码:

home.ts:

const options: CameraOptions = {
      quality: 100,
      sourceType: PictureSourceType.CAMERA,
      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
      saveToPhotoAlbum:true,
    }

    this.camera.getPicture(options).then((imageData) => {
     // imageData is either a base64 encoded string or a file URI
     // If it's base64 (DATA_URL):
     this.selectedImage = 'data:image/jpeg;base64,' + imageData;
    }, (err) => {
     // Handle error
    });    

在插件的文档中,建议将这些行添加到:

config.xml

</platform>

    <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
        <string>need camera access to take pictures</string>
    </edit-config>
    <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
        <string>need photo library access to get pictures from there</string>
    </edit-config>
    <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
        <string>need location access to find things nearby</string>
    </edit-config>
    <edit-config target="NSPhotoLibraryAddUsageDescription" file="*-Info.plist" mode="merge">
        <string>need photo library access to save pictures there</string>
    </edit-config>

0 个答案:

没有答案