notifications: fix memory leak in notification extension

- use weak delegate in adapter
- remove adapter delegate before extension stops

Change-Id: Icef7b9ea5f698c981da32a37083c8628b9a8fdbf
diff --git a/Ring/jamiNotificationExtension/AdapterService.swift b/Ring/jamiNotificationExtension/AdapterService.swift
index a39c9b1..f31441e 100644
--- a/Ring/jamiNotificationExtension/AdapterService.swift
+++ b/Ring/jamiNotificationExtension/AdapterService.swift
@@ -83,7 +83,7 @@
 
     private let maxSizeForAutoaccept = 20 * 1024 * 1024
 
-    private let adapter: Adapter
+    private var adapter: Adapter!
     var eventHandler: ((EventType, EventData) -> Void)?
     var loadingFiles = [String: EventData]()
 
@@ -118,8 +118,14 @@
         self.adapter.start(accountId)
     }
 
+    func removeDelegate() {
+        Adapter.delegate = nil
+        self.adapter = nil
+    }
+
     func stop() {
         self.adapter.stop()
+        removeDelegate()
     }
 
     func getNameFor(address: String, accountId: String) -> String {