def save_to_photo_library(jpeg_data, &block)
    photo_library.performChanges(-> {
      image = UIImage.imageWithData(jpeg_data)
      PHAssetChangeRequest.creationRequestForAssetFromImage(image)
    }, completionHandler: -> (success, error) {
      if error
        error_callback.call(error)
      else
        block.call(nil) # asset url is not returned in completion block
      end
    })
  end
def save_to_photo_library(jpeg_data, &block)
    photo_library.performChanges(-> {
      image = UIImage.imageWithData(jpeg_data)
      PHAssetChangeRequest.creationRequestForAssetFromImage(image)
    }, completionHandler: -> (success, error) {
      if error
        error_callback.call(error)
      else
        block.call(nil) # asset url is not returned in completion block
      end
    })
  end
iOS 8+