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

ScreenshotDetector Fixes #214

merged 2 commits into from Feb 11, 2017


Copy link

mliberatore commented Feb 10, 2017

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

  • Create a new "Single View Application" in Xcode
  • In, cd to its directory, and run pod init
  • Open the Podfile and add the following two lines within your target:
  pod 'PinpointKit', :git => '', :branch => 'screenshot-detector-fixes'
  pod 'PinpointKit/ScreenshotDetector', :git => '', :branch => 'screenshot-detector-fixes'
  • Run pod install
  • Close the Xcode project and open the newly created workspace
  • Add an entry for NSPhotoLibraryUsageDescription in Info.plist
  • Replace the contents of ViewController.swift with the following:
import UIKit
import PinpointKit

class ViewController: UIViewController {
    private var screenshotDetector: ScreenshotDetector?
    fileprivate let pinpointKit = PinpointKit(feedbackRecipients: [""])
    override func viewDidLoad() {
        screenshotDetector = ScreenshotDetector(delegate: self)

extension ViewController: ScreenshotDetectorDelegate {
    func screenshotDetector(_ screenshotDetector: ScreenshotDetector, didFailWith error: ScreenshotDetector.Error) {
    func screenshotDetector(_ screenshotDetector: ScreenshotDetector, didDetect screenshot: UIImage) { 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


Thanks to @iosdeveloper for finding these.


This comment has been minimized.

Copy link

iosdeveloper commented Feb 10, 2017


@mattbischoff mattbischoff merged commit f37f0c6 into develop Feb 11, 2017
1 check passed
1 check passed
buddybuild: PinpointKit (iOS, PinpointKit - Debug) Build succeeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.