         }
     }
     
-    func showNotification(_ userInfo: [AnyHashable : Any]) -> Void {
+    func application(_ application: UIApplication,
+                     didReceive notification: UILocalNotification)
+    {
+        if let category = notification.category {
+            if category == "categoryLink" {
+                debugPrint("Tapped in notification with deep link")
+            }
+        }
+    }
+
+    func application(_ application: UIApplication,
+                     handleActionWithIdentifier identifier: String?,
+                     for notification: UILocalNotification,
+                     completionHandler: @escaping () -> Void)
+    {
+        if let category = notification.category {
+            if category == "categoryLink" {
+                if let action = identifier {
+                    if action == "actionLink" {
+                        debugPrint("Tapped in deep link")
+                        if let url:String = notification.userInfo?["deep_link"] as? String
+                        {
+                            debugPrint("Will resolve deep link")
+                            SCGPush.sharedInstance().resolveTrackedLink(url)
+                        }
+                    }
+                }
+            }
+        }
+    }
+    
+    func showSilentNotification(_ userInfo: [AnyHashable : Any],
+                                fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void ) {
         if #available(iOS 10.0, *) {
 
             let body: String = (userInfo["body"] as? String)!
             
             if let messageID = userInfo["scg-message-id"] as? String {
                 if let attachmentID = userInfo["scg-attachment-id"] as? String {
-                    showMediaNotification(body, messageID: messageID, attachmentID: attachmentID)
+                    showMediaNotification(body, messageID: messageID, attachmentID: attachmentID,
+                                          userInfo: userInfo,
+                                          fetchCompletionHandler: completionHandler)
                 } else {
-                    showTextNotification(withMessageId: messageID, andBody: body)
+                    showTextNotification(withMessageId: messageID, andBody: body, userInfo: userInfo)
+                    completionHandler(UIBackgroundFetchResult.noData)
                 }
             }
         } else {

            // use the feature only available in iOS 10
            let center = UNUserNotificationCenter.current() as UNUserNotificationCenter
            setUNUserNotificationCenterDelegate(center)
            center.requestAuthorization(options: [.badge, .alert , .sound]) { (granted, error) in
                if granted {
                    application.registerForRemoteNotifications()

        } else {

            // or use some work around
            let categoryIncomingCall:UIMutableUserNotificationCategory = UIMutableUserNotificationCategory()
            categoryIncomingCall.identifier = "categoryLink"
            
            let actionAnswer:UIMutableUserNotificationAction = UIMutableUserNotificationAction()
            actionAnswer.identifier = "actionLink"
            actionAnswer.title = "Link"
            actionAnswer.activationMode = UIUserNotificationActivationMode.foreground
            
            categoryIncomingCall.setActions([actionAnswer], for: UIUserNotificationActionContext.default)
            
            let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: [categoryIncomingCall])
            application.registerUserNotificationSettings(settings)
        }
        
        let savedToken:String? = UserDefaults.standard.string(forKey: "token")
        let savedAppid:String? = UserDefaults.standard.string(forKey: "appid")
