屏幕截屏
diff --git a/platforms/ios/dlapp.xcodeproj/project.pbxproj b/platforms/ios/dlapp.xcodeproj/project.pbxproj
index a0dceb2..361fbf5 100644
--- a/platforms/ios/dlapp.xcodeproj/project.pbxproj
+++ b/platforms/ios/dlapp.xcodeproj/project.pbxproj
@@ -65,6 +65,8 @@
 		F939AD8D22BB769B006B371B /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F939AD8C22BB769B006B371B /* libsqlite3.0.tbd */; };
 		FDE92C386167415E8040F8AB /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = FDEE8379D7A34C55A616F700 /* AFURLResponseSerialization.m */; };
 		81B8C05354704A02AE1560A0 /* Fingerprint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39BDB5993A0D495C9E97E995 /* Fingerprint.swift */; };
+		F70AC332CD71455D9E103429 /* ScreenshotBlocker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD5959A12D340C3AB8685C0 /* ScreenshotBlocker.m */; };
+		1ED02270B4D74F8BB970350D /* ScreenRecordingDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = E806644FDDDD4DB9B0A7D6E4 /* ScreenRecordingDetector.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -198,6 +200,10 @@
 		FE0B455916A4481681D59FE0 /* WebKit.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
 		39BDB5993A0D495C9E97E995 /* Fingerprint.swift */ = {isa = PBXFileReference; name = "Fingerprint.swift"; path = "cordova-plugin-fingerprint-aio/Fingerprint.swift"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.swift; explicitFileType = undefined; includeInIndex = 0; };
 		705239B1B7D9402DA8A9FDA7 /* Bridging-Header.h */ = {isa = PBXFileReference; name = "Bridging-Header.h"; path = "cordova-plugin-fingerprint-aio/Bridging-Header.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
+		8BD5959A12D340C3AB8685C0 /* ScreenshotBlocker.m */ = {isa = PBXFileReference; name = "ScreenshotBlocker.m"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
+		E806644FDDDD4DB9B0A7D6E4 /* ScreenRecordingDetector.m */ = {isa = PBXFileReference; name = "ScreenRecordingDetector.m"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
+		5FA4467FDA284333A275FA08 /* ScreenshotBlocker.h */ = {isa = PBXFileReference; name = "ScreenshotBlocker.h"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
+		6C8C62629761432796084184 /* ScreenRecordingDetector.h */ = {isa = PBXFileReference; name = "ScreenRecordingDetector.h"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -409,6 +415,10 @@
 				817A61F7D48245FA9567B115 /* Brightness.h */,
 				39BDB5993A0D495C9E97E995 /* Fingerprint.swift */,
 				705239B1B7D9402DA8A9FDA7 /* Bridging-Header.h */,
+				8BD5959A12D340C3AB8685C0 /* ScreenshotBlocker.m */,
+				E806644FDDDD4DB9B0A7D6E4 /* ScreenRecordingDetector.m */,
+				5FA4467FDA284333A275FA08 /* ScreenshotBlocker.h */,
+				6C8C62629761432796084184 /* ScreenRecordingDetector.h */,
 			);
 			name = Plugins;
 			path = dlapp/Plugins;
@@ -602,6 +612,8 @@
 				1F969D21D7EF4CF1A547A1DF /* CDVWKProcessPoolFactory.m in Sources */,
 				C0A6FD40F47B434496535606 /* Brightness.m in Sources */,
 				81B8C05354704A02AE1560A0 /* Fingerprint.swift in Sources */,
+				F70AC332CD71455D9E103429 /* ScreenshotBlocker.m in Sources */,
+				1ED02270B4D74F8BB970350D /* ScreenRecordingDetector.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h
new file mode 100644
index 0000000..15e0a26
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h
@@ -0,0 +1,21 @@
+//
+//  ScreenRecordingDetector.h
+//
+
+/*
+ScreenRecordingDetector checks for screen capturing as well as airplay mirroring
+*/
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+extern NSString *kScreenRecordingDetectorRecordingStatusChangedNotification;
+
+@interface ScreenRecordingDetector : NSObject
+
++(instancetype)sharedInstance;
++ (void)triggerDetectorTimer;
++ (void)stopDetectorTimer;
+- (BOOL)isRecording;
+
+@end
\ No newline at end of file
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m
new file mode 100644
index 0000000..a7252e8
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m
@@ -0,0 +1,80 @@
+//
+//  ScreenRecordingDetector.m
+//  ScreenCaptureDetector
+//
+//
+
+#import "ScreenRecordingDetector.h"
+float const kScreenRecordingDetectorTimerInterval = 1.0;
+NSString *kScreenRecordingDetectorRecordingStatusChangedNotification = @"kScreenRecordingDetectorRecordingStatusChangedNotification";
+
+@interface ScreenRecordingDetector()
+
+@property BOOL lastRecordingState;
+@property NSTimer *timer;
+
+@end
+@implementation ScreenRecordingDetector
+
+
++ (instancetype)sharedInstance {
+    static ScreenRecordingDetector *sharedInstance = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        sharedInstance = [[self alloc] init];
+    });
+    return sharedInstance;
+}
+- (id)init {
+    if (self = [super init]) {
+        // do some init stuff here..
+        self.lastRecordingState = NO; // initially the recording state is 'NO'. This is the default state.
+        self.timer = NULL;
+    }
+    return self;
+}
+- (BOOL)isRecording {
+    for (UIScreen *screen in UIScreen.screens) {
+        if ([screen respondsToSelector:@selector(isCaptured)]) {
+            // iOS 11+ has isCaptured method.
+            if ([screen performSelector:@selector(isCaptured)]) {
+                return YES; // screen capture is active
+            } else if (screen.mirroredScreen) {
+                return YES; // mirroring is active
+            }
+        } else {
+            // iOS version below 11.0
+            if (screen.mirroredScreen)
+                return YES;
+        }
+    }
+    return NO;
+}
++ (void)triggerDetectorTimer {
+
+    ScreenRecordingDetector *detector = [ScreenRecordingDetector sharedInstance];
+    if (detector.timer) {
+        [self stopDetectorTimer];
+    }
+    detector.timer = [NSTimer scheduledTimerWithTimeInterval:kScreenRecordingDetectorTimerInterval
+                                                           target:detector
+                                                         selector:@selector(checkCurrentRecordingStatus:)
+                                                         userInfo:nil
+                                                          repeats:YES];
+}
+- (void)checkCurrentRecordingStatus:(NSTimer *)timer {
+    BOOL isRecording = [self isRecording];
+    if (isRecording != self.lastRecordingState) {
+        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+        [center postNotificationName: kScreenRecordingDetectorRecordingStatusChangedNotification object:nil];
+    }
+    self.lastRecordingState = isRecording;
+}
++ (void)stopDetectorTimer {
+    ScreenRecordingDetector *detector = [ScreenRecordingDetector sharedInstance];
+    if (detector.timer) {
+        [detector.timer invalidate];
+        detector.timer = NULL;
+    }
+}
+@end
\ No newline at end of file
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h
new file mode 100644
index 0000000..a1db059
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h
@@ -0,0 +1,10 @@
+#import <Cordova/CDV.h>
+#import "ScreenRecordingDetector.h"
+
+
+@interface ScreenshotBlocker : CDVPlugin
+
+- (void)enable:(CDVInvokedUrlCommand*)command;
+-(void)listen:(CDVInvokedUrlCommand*)command;
+
+@end
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m
new file mode 100644
index 0000000..8397d55
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m
@@ -0,0 +1,119 @@
+#import "ScreenshotBlocker.h"
+@interface ScreenshotBlocker() {
+    CDVInvokedUrlCommand * _eventCommand;
+}
+@end
+
+@implementation ScreenshotBlocker
+UIImageView* cover;
+- (void)pluginInitialize {
+    NSLog(@"Starting ScreenshotBlocker plugin");
+
+    [[NSNotificationCenter defaultCenter]addObserver:self
+                                            selector:@selector(appDidBecomeActive)
+                                                name:UIApplicationDidBecomeActiveNotification
+                                              object:nil];
+    [[NSNotificationCenter defaultCenter]addObserver:self
+                                            selector:@selector(applicationWillResignActive)
+                                                name:UIApplicationWillResignActiveNotification
+                                              object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(tookScreeshot)
+                                                 name:UIApplicationUserDidTakeScreenshotNotification
+                                               object:nil];
+
+    [[NSNotificationCenter defaultCenter]addObserver:self
+                                            selector:@selector(goingBackground)
+                                                name:UIApplicationWillResignActiveNotification
+                                              object:nil];
+
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(screenCaptureStatusChanged)
+                                                 name:kScreenRecordingDetectorRecordingStatusChangedNotification
+                                               object:nil];
+
+    /*
+     userDidTakeScreenshotNotification
+     */
+
+}
+
+- (void)enable:(CDVInvokedUrlCommand *)command
+{
+    CDVPluginResult* pluginResult = nil;
+    NSLog(@"Abilita observers");
+    /*
+     [[NSNotificationCenter defaultCenter]addObserver:self
+     selector:@selector(appDidBecomeActive)
+     name:UIApplicationDidBecomeActiveNotification
+     object:nil];
+     [[NSNotificationCenter defaultCenter]addObserver:self
+     selector:@selector(applicationWillResignActive)
+     name:UIApplicationWillResignActiveNotification
+     object:nil];
+     [[NSNotificationCenter defaultCenter] addObserver:self
+     selector:@selector(screenCaptureStatusChanged)
+     name:kScreenRecordingDetectorRecordingStatusChangedNotification
+     object:nil];
+     pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+     */
+}
+-(void)listen:(CDVInvokedUrlCommand*)command {
+    _eventCommand = command;
+}
+
+
+-(void) goingBackground {
+    NSLog(@"Me la scattion in bck");
+    if(_eventCommand!=nil) {
+        CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"background"];
+        [pluginResult setKeepCallbackAsBool:YES];
+        [self.commandDelegate sendPluginResult:pluginResult callbackId:_eventCommand.callbackId];
+    }
+}
+-(void)tookScreeshot {
+    NSLog(@"fatta la foto?");
+    if(_eventCommand!=nil) {
+        CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"tookScreenshot"];
+        [pluginResult setKeepCallbackAsBool:YES];
+        [self.commandDelegate sendPluginResult:pluginResult callbackId:_eventCommand.callbackId];
+    }
+
+}
+
+-(void)setupView {
+    BOOL isCaptured = [[UIScreen mainScreen] isCaptured];
+    NSLog(@"Is screen captured? %@", (isCaptured?@"SI":@"NO"));
+
+    if ([[ScreenRecordingDetector sharedInstance] isRecording]) {
+        [self webView].alpha = 0.f;
+        NSLog(@"Registro o prendo screenshots");
+    } else {
+        [self webView].alpha = 1.f;
+        NSLog(@"Non registro");
+
+    }
+}
+
+-(void)appDidBecomeActive {
+    [ScreenRecordingDetector triggerDetectorTimer];
+    if(cover!=nil) {
+        [cover removeFromSuperview];
+        cover = nil;
+    }
+}
+-(void)applicationWillResignActive {
+    [ScreenRecordingDetector stopDetectorTimer];
+    if(cover == nil) {
+        cover = [[UIImageView alloc] initWithFrame:[self.webView frame]];
+        cover.backgroundColor = [UIColor blackColor];
+        [self.webView addSubview:cover];
+    }
+}
+-(void)screenCaptureStatusChanged {
+    [self setupView];
+}
+
+
+@end
diff --git a/platforms/ios/dlapp/config.xml b/platforms/ios/dlapp/config.xml
index 90986af..8fb53bc 100755
--- a/platforms/ios/dlapp/config.xml
+++ b/platforms/ios/dlapp/config.xml
@@ -67,6 +67,10 @@
     <feature name="Fingerprint">
         <param name="ios-package" value="Fingerprint" />
     </feature>
+    <feature name="screenshotName">
+        <param name="ios-package" value="ScreenshotBlocker" />
+        <param name="onload" value="true" />
+    </feature>
     <name short="大理智警">dlapp</name>
     <description>
         A sample Apache Cordova application that responds to the deviceready event.
diff --git a/platforms/ios/ios.json b/platforms/ios/ios.json
index 8247df1..2cc797d 100644
--- a/platforms/ios/ios.json
+++ b/platforms/ios/ios.json
@@ -83,6 +83,10 @@
             {
               "xml": "<feature name=\"Fingerprint\"><param name=\"ios-package\" value=\"Fingerprint\" /></feature>",
               "count": 1
+            },
+            {
+              "xml": "<feature name=\"screenshotName\"><param name=\"ios-package\" value=\"ScreenshotBlocker\" /><param name=\"onload\" value=\"true\" /></feature>",
+              "count": 1
             }
           ]
         }
@@ -209,6 +213,9 @@
     "cordova-plugin-fingerprint-aio": {
       "FACEID_USAGE_DESCRIPTION": " ",
       "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
+    },
+    "cordova-plugin-prevent-screenshot-coffice": {
+      "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
     }
   },
   "dependent_plugins": {},
@@ -572,6 +579,14 @@
       "clobbers": [
         "Fingerprint"
       ]
+    },
+    {
+      "id": "cordova-plugin-prevent-screenshot-coffice.screenshot",
+      "file": "plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js",
+      "pluginId": "cordova-plugin-prevent-screenshot-coffice",
+      "clobbers": [
+        "window.plugins.preventscreenshot"
+      ]
     }
   ],
   "plugin_metadata": {
@@ -592,6 +607,7 @@
     "cordova-plugin-app-version": "0.1.9",
     "cordova-plugin-wkwebview-engine": "1.2.1",
     "cordova-plugin-brightness": "0.1.5",
-    "cordova-plugin-fingerprint-aio": "3.0.1"
+    "cordova-plugin-fingerprint-aio": "3.0.1",
+    "cordova-plugin-prevent-screenshot-coffice": "1.0.1"
   }
 }
diff --git a/platforms/ios/platform_www/cordova_plugins.js b/platforms/ios/platform_www/cordova_plugins.js
index ed613ac..b4d865e 100644
--- a/platforms/ios/platform_www/cordova_plugins.js
+++ b/platforms/ios/platform_www/cordova_plugins.js
@@ -359,6 +359,14 @@
       "clobbers": [
         "Fingerprint"
       ]
+    },
+    {
+      "id": "cordova-plugin-prevent-screenshot-coffice.screenshot",
+      "file": "plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js",
+      "pluginId": "cordova-plugin-prevent-screenshot-coffice",
+      "clobbers": [
+        "window.plugins.preventscreenshot"
+      ]
     }
   ];
   module.exports.metadata = {
@@ -379,6 +387,7 @@
     "cordova-plugin-app-version": "0.1.9",
     "cordova-plugin-wkwebview-engine": "1.2.1",
     "cordova-plugin-brightness": "0.1.5",
-    "cordova-plugin-fingerprint-aio": "3.0.1"
+    "cordova-plugin-fingerprint-aio": "3.0.1",
+    "cordova-plugin-prevent-screenshot-coffice": "1.0.1"
   };
 });
\ No newline at end of file
diff --git a/platforms/ios/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js b/platforms/ios/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js
new file mode 100644
index 0000000..eaf17d5
--- /dev/null
+++ b/platforms/ios/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js
@@ -0,0 +1,40 @@
+cordova.define("cordova-plugin-prevent-screenshot-coffice.screenshot", function(require, exports, module) {
+var screenshot = {
+  enable: function (successCallback, errorCallback) {
+    cordova.exec(successCallback, errorCallback, 'screenshotName', 'enable', []);
+  },
+  disable: function (successCallback, errorCallback) {
+    cordova.exec(successCallback, errorCallback, 'screenshotName', 'disable', []);
+  },
+  registerListener : function(callback) {
+    cordova.exec(callback, callback, 'screenshotName', 'listen', []);
+
+  }
+}
+
+cordova.addConstructor(function () {
+  if (!window.plugins) {window.plugins = {};}
+
+  window.plugins.preventscreenshot = screenshot;
+  document.addEventListener("onTookScreenshot",function(){
+    console.log('tookScreenshot');
+  });
+  document.addEventListener("onGoingBackground",function(){
+    console.log('BackgroundCalled');
+  });
+  screenshot.registerListener(function(me) {
+    console.log('received listener:',me);
+    if(me === "background") {
+      var event = new Event('onGoingBackground');
+      document.dispatchEvent(event);
+      return;
+    }
+    if(me === "tookScreenshot") {
+      var event = new Event('onTookScreenshot');
+      document.dispatchEvent(event);
+      return;
+    }
+  });
+  return window.plugins.preventscreenshot;
+});
+});