-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix an issue that delete token does not trigger token refresh notification or delegate #5339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e5c23d2
b711c76
8590ec0
8b6abe3
b24f4ab
4c7cab1
99b12e4
d9c4389
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Scheme | ||
| LastUpgradeVersion = "1120" | ||
| version = "1.3"> | ||
| <BuildAction | ||
| parallelizeBuildables = "YES" | ||
| buildImplicitDependencies = "YES"> | ||
| <BuildActionEntries> | ||
| <BuildActionEntry | ||
| buildForTesting = "YES" | ||
| buildForRunning = "YES" | ||
| buildForProfiling = "YES" | ||
| buildForArchiving = "YES" | ||
| buildForAnalyzing = "YES"> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "5125CC982437F471006CA5D0" | ||
| BuildableName = "Sample.app" | ||
| BlueprintName = "Sample" | ||
| ReferencedContainer = "container:Sample.xcodeproj"> | ||
| </BuildableReference> | ||
| </BuildActionEntry> | ||
| </BuildActionEntries> | ||
| </BuildAction> | ||
| <TestAction | ||
| buildConfiguration = "Debug" | ||
| selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| shouldUseLaunchSchemeArgsEnv = "YES"> | ||
| <Testables> | ||
| </Testables> | ||
| </TestAction> | ||
| <LaunchAction | ||
| buildConfiguration = "Debug" | ||
| selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| launchStyle = "0" | ||
| useCustomWorkingDirectory = "NO" | ||
| ignoresPersistentStateOnLaunch = "NO" | ||
| debugDocumentVersioning = "YES" | ||
| debugServiceExtension = "internal" | ||
| allowLocationSimulation = "YES"> | ||
| <BuildableProductRunnable | ||
| runnableDebuggingMode = "0"> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "5125CC982437F471006CA5D0" | ||
| BuildableName = "Sample.app" | ||
| BlueprintName = "Sample" | ||
| ReferencedContainer = "container:Sample.xcodeproj"> | ||
| </BuildableReference> | ||
| </BuildableProductRunnable> | ||
| <CommandLineArguments> | ||
| <CommandLineArgument | ||
| argument = "-FIRDebugEnabled" | ||
| isEnabled = "YES"> | ||
| </CommandLineArgument> | ||
| </CommandLineArguments> | ||
| </LaunchAction> | ||
| <ProfileAction | ||
| buildConfiguration = "Release" | ||
| shouldUseLaunchSchemeArgsEnv = "YES" | ||
| savedToolIdentifier = "" | ||
| useCustomWorkingDirectory = "NO" | ||
| debugDocumentVersioning = "YES"> | ||
| <BuildableProductRunnable | ||
| runnableDebuggingMode = "0"> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "5125CC982437F471006CA5D0" | ||
| BuildableName = "Sample.app" | ||
| BlueprintName = "Sample" | ||
| ReferencedContainer = "container:Sample.xcodeproj"> | ||
| </BuildableReference> | ||
| </BuildableProductRunnable> | ||
| </ProfileAction> | ||
| <AnalyzeAction | ||
| buildConfiguration = "Debug"> | ||
| </AnalyzeAction> | ||
| <ArchiveAction | ||
| buildConfiguration = "Release" | ||
| revealArchiveInOrganizer = "YES"> | ||
| </ArchiveAction> | ||
| </Scheme> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, MessagingDelegate { | |
| options connectionOptions: UIScene.ConnectionOptions) { | ||
| let contentView = ContentView() | ||
| // Use a UIHostingController as window root view controller. | ||
| Messaging.messaging().delegate = self | ||
| if let windowScene = scene as? UIWindowScene { | ||
| let window = UIWindow(windowScene: windowScene) | ||
| window | ||
|
|
@@ -35,12 +34,27 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, MessagingDelegate { | |
| self.window = window | ||
| window.makeKeyAndVisible() | ||
| } | ||
| } | ||
|
|
||
| func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) { | ||
| identity.token = fcmToken | ||
| InstanceID.instanceID().instanceID { result, error in | ||
| self.identity.instanceID = result?.instanceID | ||
| } | ||
| // Subscribe to token refresh | ||
| _ = NotificationCenter.default | ||
| .publisher(for: Notification.Name.MessagingRegistrationTokenRefreshed) | ||
| .map { $0.object as? String } | ||
| .receive(on: RunLoop.main) | ||
| .assign(to: \Identity.token, on: identity) | ||
|
Comment on lines
+39
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe you'll need to store these |
||
|
|
||
| // Subscribe to fid changes | ||
| _ = NotificationCenter.default | ||
| .publisher(for: Notification.Name.FIRInstallationIDDidChange) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh - looks like we need to change the API name here as well (shouldn't have a FIR prefix). |
||
| .map { _ in } | ||
| .receive(on: RunLoop.main) | ||
| .sink(receiveValue: { | ||
| Installations.installations().installationID(completion: { fid, error in | ||
| if let error = error as NSError? { | ||
| print("Failed to get FID: ", error) | ||
| return | ||
| } | ||
| self.identity.instanceID = fid ?? "None" | ||
| }) | ||
| }) | ||
|
Comment on lines
+51
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the notification not include information about the FID? If not we should look at adding it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
nilif it doesn't exist, right? Otherwise consumers of this could think that an instanceID is available but the String is actually "None" which isn't valid.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Good catch!