12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ import Combine
15
16
import UIKit
16
17
import SwiftUI
17
18
import FirebaseInstanceID
@@ -21,6 +22,7 @@ import FirebaseInstallations
21
22
class SceneDelegate : UIResponder , UIWindowSceneDelegate , MessagingDelegate {
22
23
var window : UIWindow ?
23
24
let identity = Identity ( )
25
+ var cancellables = Set < AnyCancellable > ( )
24
26
25
27
func scene( _ scene: UIScene , willConnectTo session: UISceneSession ,
26
28
options connectionOptions: UIScene . ConnectionOptions ) {
@@ -41,6 +43,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, MessagingDelegate {
41
43
. map { $0. object as? String }
42
44
. receive ( on: RunLoop . main)
43
45
. assign ( to: \Identity . token, on: identity)
46
+ . store ( in: & cancellables)
44
47
45
48
// Subscribe to fid changes
46
49
_ = NotificationCenter . default
@@ -53,8 +56,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, MessagingDelegate {
53
56
print ( " Failed to get FID: " , error)
54
57
return
55
58
}
56
- self . identity. instanceID = fid ?? " None "
59
+ self . identity. instanceID = fid
57
60
} )
58
61
} )
62
+ . store ( in: & cancellables)
59
63
}
60
64
}
0 commit comments