Lickability / PinpointKit

Send better feedback
MIT License
1.13k stars 79 forks source link

ScreenshotDetector Fixes #214

Closed mliberatore closed 7 years ago

mliberatore commented 7 years ago

Closes #211

What It Does

Fixes two issues with ScreenshotDetector brought up in #211:

  1. The permission alert for accessing the user’s photo library was appearing prematurely. Now it appears at the time we need to first access the photo library.
  2. The fetched screenshot delivered in the delegate was the second-to-most-recent screenshot in the user’s library. We now wait for a change to the photo library before fetching the screenshot to deliver.

How to Test

  pod 'PinpointKit', :git => 'https://github.com/Lickability/PinpointKit.git', :branch => 'screenshot-detector-fixes'
  pod 'PinpointKit/ScreenshotDetector', :git => 'https://github.com/Lickability/PinpointKit.git', :branch => 'screenshot-detector-fixes'

class ViewController: UIViewController { private var screenshotDetector: ScreenshotDetector? fileprivate let pinpointKit = PinpointKit(feedbackRecipients: ["feedback@example.com"])

override func viewDidLoad() {
    super.viewDidLoad()

    screenshotDetector = ScreenshotDetector(delegate: self)
}

}

extension ViewController: ScreenshotDetectorDelegate {

func screenshotDetector(_ screenshotDetector: ScreenshotDetector, didFailWith error: ScreenshotDetector.Error) {
    print(error)
}

func screenshotDetector(_ screenshotDetector: ScreenshotDetector, didDetect screenshot: UIImage) {
    pinpointKit.show(from: self, screenshot: screenshot)
}

}


* Run the app on a device, noticing that you’re not immediately prompted for access to your photo library
* Make note of the time in the status bar
* Take a screenshot and accept the correctly-timed prompt
* Confirm that the time you noted matches that of the screenshot presented by PinpointKit
* Repeat taking screenshots until you’re satisfied that the latest screenshot is always used

## Notes

Thanks to @iosdeveloper for finding these.
iosdeveloper commented 7 years ago

👍