feat(EMT-2878): integrate modern SessionManager with async/await#15
Open
wpinho-branch wants to merge 11 commits intogptdriver/linkingTestsfrom
Open
feat(EMT-2878): integrate modern SessionManager with async/await#15wpinho-branch wants to merge 11 commits intogptdriver/linkingTestsfrom
wpinho-branch wants to merge 11 commits intogptdriver/linkingTestsfrom
Conversation
- Remove conflict markers from .gitignore - Keep xcodeproj tracked (not ignored) - Comment out SPM-related ignores to allow project tracking
Replace callback-based Branch initialization with the new Swift SessionManager that provides task coalescing for Double Open prevention. Changes: - Add BranchSwiftSDK import for SessionManager access - Add sessionState property to DeepLinkViewModel for UI observation - Create BranchSessionCoordinator reference for modern API access - Implement initializeWithModernSessionManager using async/await - Add observeSessionState using AsyncStream for reactive state updates - Update handleSessionInitialized to convert Session to legacy params - Refactor Universal Links handler to use SessionManager - Refactor URL Scheme handler to use SessionManager - Use SessionState.description for human-readable state display The new SessionManager provides: - Task coalescing (prevents duplicate API calls) - Async/await API (modern Swift patterns) - Actor-based thread safety (Swift 6 concurrency) - AsyncStream state observation (reactive updates)
…leState Remove manual session state management from app - now handled by SDK. Changes: - Remove @published sessionState from DeepLinkViewModel - Remove observeSessionState() method and Task loop - Add documentation comments for SDK's BranchObservableState usage The SDK now provides BranchObservableState (ObservableObject) that can be used directly in SwiftUI views via: @ObservedObject var branchState = BranchSessionCoordinator.shared.observableState This eliminates the need for apps to manually bridge AsyncStream to @published.
…er usage - Update onOpenURL to use SessionManager instead of legacy Branch.handleDeepLink() - Use InitializationOptions builder pattern (SDK's .with(launchOptions:)) - Add handleSessionForUI() method for centralized UI updates - Add @mainactor to initializeWithModernSessionManager for builder pattern - Import BranchSwiftSDK in BranchLinkSimulatorApp for SessionManager access This ensures task coalescing works correctly across all entry points: - didFinishLaunchingWithOptions - continueUserActivity (Universal Links) - application:open:options: (URL Schemes) - onOpenURL (SwiftUI)
- Configure DefaultBranchNetworkService.logCallback in AppDelegate - Add processSwiftNetworkLog method to RoundTripStore - Now displays network requests from the new Swift SessionManager
Replace callback-based logging (DefaultBranchNetworkService.logCallback) with modern Swift Concurrency using AsyncStream: - Add logObserverTask property to manage the async observation lifecycle - Implement startNetworkLogObserver() using for-await pattern - Add processNetworkLogEntry() with @mainactor isolation for thread safety - Add deinit to properly cancel the observer task Benefits: - Eliminates race conditions (AsyncStream buffers logs until observer attaches) - Uses reactive for-await processing instead of imperative callbacks - Thread-safe via Actor isolation - Automatic lifecycle management
…ted logging - Use SessionManager.shared for SDK initialization - Consolidate logging to single Branch.enableLogging(at:callback:) call - Remove redundant BranchLogObserver setup - Process network logs via RoundTripStore for API debugging - Handle deep links via SessionManager.handleDeepLink() The Modern SessionManager provides: - Task coalescing to prevent "Double Open" issue - Async callback API for session initialization - Deep link data via Session.params dictionary
BranchLinkSimulatorApp: - Clean up app entry point - Proper environment object injection HomeView: - Update logging calls to use BranchLogger.shared() - Simplify event sending and link creation - Remove unused code
- Remove BranchSwiftSDK dependency (module no longer exists) - Replace SessionManager.shared with Branch.getInstance() - Use initSession(launchOptions:) instead of Swift SessionManager - Use handleDeepLink(url) for universal links and URL schemes - Remove unused processSwiftNetworkLog method from RoundTripStore The Swift SessionManagement layer was removed from BranchSDK as unnecessary complexity. This update uses the standard Objective-C SDK methods directly.
…d safety - Use explicit parameter labels for enableLogging(at:withAdvancedCallback:) and initSession(launchOptions:andRegisterDeepLinkHandler:) - Add [weak self] capture to SDK callbacks to prevent retain cycles - Dispatch deepLinkViewModel updates to main thread (errorItem, deepLinkData, deepLinkHandled) to avoid @published mutation off main
…dition - Replace NavigationView with NavigationStack (deprecated in iOS 16) - Replace NavigationLink(isActive:) with navigationDestination(isPresented:) - Fix QR code sheet showing "No QR Code Available" on first tap by removing separate showingQRSheet state and driving sheet presentation directly from qrCodeImage via computed Binding - Rename event callback parameter from result to success to match ObjC API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Integrate the new Swift SessionManager into BranchLinkSimulator to test the modern async/await API with task coalescing for Double Open prevention (INTENG-21106).
Changes
SPM Integration
BranchSDK.xcframeworkreference../ios-branch-deep-linking-attributionBranchSDKpackage product dependencyModern SessionManager Integration
BranchSwiftSDKimport for SessionManager accessBranchSessionCoordinator.shared.sessionManagerfor modern APIinitSessionwith async/awaitinitialize(options:)AsyncStream<SessionState>Technical Details
The new SessionManager provides:
initialize()calls are merged into a single API requestTesting
Related: EMT-2878, INTENG-21106