@@ -82,22 +82,37 @@ private static extern int RegQueryValueEx(
8282 /// <param name="callback">Callback to invoke when a deep link is received</param>
8383 public static void Initialise ( string redirectUri , Action < string > callback )
8484 {
85+ PassportLogger . Info ( $ "[WindowsDeepLink] ===== INITIALISE CALLED =====") ;
86+ PassportLogger . Info ( $ "[WindowsDeepLink] redirectUri: { redirectUri } ") ;
87+ PassportLogger . Info ( $ "[WindowsDeepLink] callback: { ( callback == null ? "NULL" : "PROVIDED" ) } ") ;
88+ PassportLogger . Info ( $ "[WindowsDeepLink] _instance: { ( _instance == null ? "NULL - will create new" : "EXISTS - will reuse" ) } ") ;
89+
8590 if ( _instance == null )
8691 {
8792 _instance = new GameObject ( nameof ( WindowsDeepLink ) ) . AddComponent < WindowsDeepLink > ( ) ;
8893 DontDestroyOnLoad ( _instance . gameObject ) ;
94+ PassportLogger . Info ( $ "[WindowsDeepLink] Created new WindowsDeepLink GameObject") ;
8995 }
9096
91- if ( string . IsNullOrEmpty ( redirectUri ) ) return ;
97+ if ( string . IsNullOrEmpty ( redirectUri ) )
98+ {
99+ PassportLogger . Warn ( $ "[WindowsDeepLink] redirectUri is null or empty! Returning early.") ;
100+ return ;
101+ }
92102
93103 // Extract protocol name from URI (e.g. "immutable" from "immutable://")
94104 var protocolName = redirectUri . Split ( new [ ] { "://" } , StringSplitOptions . None ) [ 0 ] ;
105+ PassportLogger . Info ( $ "[WindowsDeepLink] Extracted protocol name: '{ protocolName } '") ;
106+
95107 _instance . _protocolName = protocolName ;
96108 _instance . _callback = callback ;
97109
98110 // Register protocol and create handler script
111+ PassportLogger . Info ( $ "[WindowsDeepLink] Registering protocol '{ protocolName } '...") ;
99112 RegisterProtocol ( protocolName ) ;
113+ PassportLogger . Info ( $ "[WindowsDeepLink] Creating command script for protocol '{ protocolName } '...") ;
100114 CreateCommandScript ( protocolName ) ;
115+ PassportLogger . Info ( $ "[WindowsDeepLink] ===== INITIALISE COMPLETED =====") ;
101116 }
102117
103118 private static void CreateCommandScript ( string protocolName )
@@ -341,9 +356,12 @@ private static string GetGameExecutablePath(string suffix)
341356
342357 private void OnApplicationFocus ( bool hasFocus )
343358 {
359+ PassportLogger . Debug ( $ "[WindowsDeepLink] OnApplicationFocus: hasFocus={ hasFocus } ") ;
360+
344361 // Only handle deeplink when application regains focus
345362 if ( ! hasFocus ) return ;
346363
364+ PassportLogger . Info ( $ "[WindowsDeepLink] Application gained focus - checking for deeplink...") ;
347365 HandleDeeplink ( ) ;
348366 }
349367
@@ -356,11 +374,14 @@ private void Update()
356374 if ( Time . unscaledTime < _nextPollAt ) return ;
357375 _nextPollAt = Time . unscaledTime + POLL_INTERVAL_SECONDS ;
358376
377+ PassportLogger . Debug ( $ "[WindowsDeepLink] Polling for deeplink (every { POLL_INTERVAL_SECONDS } s)...") ;
359378 HandleDeeplink ( ) ;
360379 }
361380
362381 private void HandleDeeplink ( )
363382 {
383+ PassportLogger . Debug ( $ "[WindowsDeepLink] HandleDeeplink called - checking registry for protocol '{ _protocolName } '") ;
384+
364385 // Open registry key for the protocol
365386 var registryPath = $@ "Software\Classes\{ _protocolName } ";
366387 UIntPtr hKey ;
@@ -373,10 +394,12 @@ private void HandleDeeplink()
373394
374395 if ( result != 0 )
375396 {
376- PassportLogger . Error ( $ "Failed to open registry key. Error code: { result } ") ;
397+ PassportLogger . Error ( $ "[WindowsDeepLink] Failed to open registry key ' { registryPath } ' . Error code: { result } ") ;
377398 return ;
378399 }
379400
401+ PassportLogger . Debug ( $ "[WindowsDeepLink] Successfully opened registry key '{ registryPath } '") ;
402+
380403 // Get size of deeplink data
381404 uint type = 0 ;
382405 uint dataSize = 0 ;
@@ -388,11 +411,17 @@ private void HandleDeeplink()
388411 // No deeplink written yet; don't spam logs on each poll.
389412 if ( result != ERROR_FILE_NOT_FOUND )
390413 {
391- PassportLogger . Warn ( $ "Failed to get deeplink data size. Error code: { result } ") ;
414+ PassportLogger . Warn ( $ "[WindowsDeepLink] Failed to get deeplink data size from registry. Error code: { result } ") ;
415+ }
416+ else
417+ {
418+ PassportLogger . Debug ( $ "[WindowsDeepLink] No deeplink found in registry yet (ERROR_FILE_NOT_FOUND)") ;
392419 }
393420 return ;
394421 }
395422
423+ PassportLogger . Info ( $ "[WindowsDeepLink] ✓ Found deeplink in registry! dataSize={ dataSize } ") ;
424+
396425 // Read deeplink data
397426 var data = new byte [ dataSize ] ;
398427 result = RegQueryValueEx ( hKey , REGISTRY_DEEP_LINK_NAME , IntPtr . Zero , ref type , data , ref dataSize ) ;
@@ -402,20 +431,24 @@ private void HandleDeeplink()
402431 {
403432 // Convert and validate URI
404433 var uri = System . Text . Encoding . Unicode . GetString ( data , 0 , ( int ) dataSize - 2 ) ; // Remove null terminator
434+ PassportLogger . Info ( $ "[WindowsDeepLink] Read deeplink URI from registry: '{ uri } '") ;
435+
405436 if ( _protocolName != null && ! uri . StartsWith ( _protocolName ) )
406437 {
407- PassportLogger . Error ( $ "Incorrect prefix uri { uri } ") ;
438+ PassportLogger . Error ( $ "[WindowsDeepLink] ✗ Incorrect protocol prefix! Expected ' { _protocolName } ://' but got ' { uri } ' ") ;
408439 }
409440 else
410441 {
411442 // Invoke callback with valid URI
443+ PassportLogger . Info ( $ "[WindowsDeepLink] ✓ Valid URI - invoking callback...") ;
412444 _callback ? . Invoke ( uri ) ;
413445 callbackInvoked = true ;
446+ PassportLogger . Info ( $ "[WindowsDeepLink] Callback invoked successfully") ;
414447 }
415448 }
416449 else
417450 {
418- PassportLogger . Warn ( $ "Failed to get registry key . Error code: { result } ") ;
451+ PassportLogger . Warn ( $ "[WindowsDeepLink] Failed to read deeplink from registry . Error code: { result } , type: { type } ") ;
419452 }
420453
421454 // Clean up registry handle
@@ -424,37 +457,41 @@ private void HandleDeeplink()
424457 // Delete registry key if callback was invoked
425458 if ( callbackInvoked )
426459 {
460+ PassportLogger . Info ( $ "[WindowsDeepLink] Deleting registry key '{ registryPath } '...") ;
427461 result = RegDeleteTree ( ( UIntPtr ) HKEY_CURRENT_USER , registryPath ) ;
428462
429463 if ( result != 0 )
430464 {
431- PassportLogger . Warn ( $ "Failed to delete registry key. Error code: { result } ") ;
465+ PassportLogger . Warn ( $ "[WindowsDeepLink] Failed to delete registry key. Error code: { result } ") ;
432466 }
433467 else
434468 {
435- PassportLogger . Debug ( " Successfully deleted registry key.") ;
469+ PassportLogger . Info ( $ "[WindowsDeepLink] Successfully deleted registry key.") ;
436470 }
437471 }
438472 else
439473 {
440- PassportLogger . Debug ( " Did not invoke callback so not deleting registry key.") ;
474+ PassportLogger . Debug ( $ "[WindowsDeepLink] Did not invoke callback so not deleting registry key.") ;
441475 }
442476
443477 // Clean up command script
444478 var cmdPath = GetGameExecutablePath ( ".cmd" ) ;
445479 if ( File . Exists ( cmdPath ) )
446480 {
481+ PassportLogger . Info ( $ "[WindowsDeepLink] Deleting command script: { cmdPath } ") ;
447482 try
448483 {
449484 File . Delete ( cmdPath ) ;
485+ PassportLogger . Info ( $ "[WindowsDeepLink] Command script deleted successfully") ;
450486 }
451487 catch ( Exception ex )
452488 {
453- PassportLogger . Warn ( $ "Failed to delete script: { ex . Message } ") ;
489+ PassportLogger . Warn ( $ "[WindowsDeepLink] Failed to delete script: { ex . Message } ") ;
454490 }
455491 }
456492
457493 // Clean up instance
494+ PassportLogger . Info ( $ "[WindowsDeepLink] Destroying WindowsDeepLink GameObject and clearing instance") ;
458495 Destroy ( gameObject ) ;
459496 _instance = null ;
460497 }
0 commit comments