Fixes two issues with ScreenshotDetector brought up in #211:
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.
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 Terminal.app, cd to its directory, and run pod init
Open the Podfile and add the following two lines within your target:
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'
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: ["feedback@example.com"])
* 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.
Closes #211
What It Does
Fixes two issues with
ScreenshotDetector
brought up in #211:How to Test
cd
to its directory, and runpod init
pod install
NSPhotoLibraryUsageDescription
inInfo.plist
ViewController.swift
with the following:class ViewController: UIViewController { private var screenshotDetector: ScreenshotDetector? fileprivate let pinpointKit = PinpointKit(feedbackRecipients: ["feedback@example.com"])
}
extension ViewController: ScreenshotDetectorDelegate {
}