     
     internal func takeScreenshot() -> UIImage? {
         
-        let orientation = UIApplication.sharedApplication().statusBarOrientation
-        let imageSize: CGSize = UIScreen.mainScreen().bounds.size
-        let layer = UIApplication.sharedApplication().keyWindow?.layer
-        let scale = UIScreen.mainScreen().scale
+        let orientation = UIApplication.shared.statusBarOrientation
+        let imageSize: CGSize = UIScreen.main.bounds.size
+        let layer = UIApplication.shared.keyWindow?.layer
+        let scale = UIScreen.main.scale
         UIGraphicsBeginImageContextWithOptions(imageSize, false, scale);
-        layer?.renderInContext(UIGraphicsGetCurrentContext()!)
+        layer?.render(in: UIGraphicsGetCurrentContext()!)
         let screenshot = UIGraphicsGetImageFromCurrentImageContext()
         UIGraphicsEndImageContext()
         
         var imageOrientation: UIImageOrientation
         switch orientation {
-        case .LandscapeLeft:
-            imageOrientation = UIImageOrientation.Left
+        case .landscapeLeft:
+            imageOrientation = UIImageOrientation.left
             break
-        case .LandscapeRight:
-            imageOrientation = UIImageOrientation.Right
+        case .landscapeRight:
+            imageOrientation = UIImageOrientation.right
             break
-        case .PortraitUpsideDown:
-            imageOrientation = UIImageOrientation.Down
+        case .portraitUpsideDown:
+            imageOrientation = UIImageOrientation.down
             break
-        case .Unknown, .Portrait:
-            imageOrientation = UIImageOrientation.Up
+        case .unknown, .portrait:
+            imageOrientation = UIImageOrientation.up
             break
         }
-        let image = UIImage(CGImage: screenshot.CGImage!, scale: screenshot.scale, orientation: imageOrientation)
+        let image = UIImage(cgImage: (screenshot?.cgImage!)!, scale: (screenshot?.scale)!, orientation: imageOrientation)
         return image
     }
     
     deinit {
-        NSNotificationCenter.defaultCenter().removeObserver(
+        NotificationCenter.default.removeObserver(
             self,
-            name: Notification.ButterflyDidShakingNotification,
+            name: NSNotification.Name(rawValue: Notification.ButterflyDidShakingNotification),
             object: nil)
     }
 }

    
    /// Register and start listening shake event.
    /// Register this method in AppDelegate will listen all motions during the whole application's life cycle.
    public func startListeningShake() {
        NSNotificationCenter.defaultCenter().addObserver(
            self,
            selector: #selector(handleShake),
            name: Notification.ButterflyDidShakingNotification,
            object: nil)
        isListeningShake = true
    }

    ///
    /// That would be a great idea to upload your useful application information here manually .
    
    func ButterflyViewControllerDidPressedSendButton(_ drawView: ButterflyDrawView?) {

        if let image = imageWillUpload {
            let data: UIImage = image
