Kaynağa Gözat

fix a few places (#5370)

Chen Liang 6 yıl önce
ebeveyn
işleme
b279805779

+ 1 - 1
Example/Messaging/Sample/Sample/Identity.swift

@@ -28,7 +28,7 @@ public final class Identity: ObservableObject {
         print("Failed to get FID: ", error)
         return
       }
-      self.instanceID = fid ?? "None"
+      self.instanceID = fid
     })
   }
 }

+ 5 - 1
Example/Messaging/Sample/Sample/SceneDelegate.swift

@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+import Combine
 import UIKit
 import SwiftUI
 import FirebaseInstanceID
@@ -21,6 +22,7 @@ import FirebaseInstallations
 class SceneDelegate: UIResponder, UIWindowSceneDelegate, MessagingDelegate {
   var window: UIWindow?
   let identity = Identity()
+  var cancellables = Set<AnyCancellable>()
 
   func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
              options connectionOptions: UIScene.ConnectionOptions) {
@@ -41,6 +43,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, MessagingDelegate {
       .map { $0.object as? String }
       .receive(on: RunLoop.main)
       .assign(to: \Identity.token, on: identity)
+      .store(in: &cancellables)
 
     // Subscribe to fid changes
     _ = NotificationCenter.default
@@ -53,8 +56,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, MessagingDelegate {
             print("Failed to get FID: ", error)
             return
           }
-          self.identity.instanceID = fid ?? "None"
+          self.identity.instanceID = fid
           })
         })
+      .store(in: &cancellables)
   }
 }