@@ -29,7 +29,7 @@ public partial class AppViewModel : ObservableObject
2929 private string _userStatus = "Anonymous" ;
3030
3131 [ ObservableProperty ]
32- private string _externalIdDisplay = "– " ;
32+ private string _externalIdDisplay = "— " ;
3333
3434 [ ObservableProperty ]
3535 private bool _isLoggedIn ;
@@ -39,7 +39,7 @@ public partial class AppViewModel : ObservableObject
3939
4040 // Push section
4141 [ ObservableProperty ]
42- private string _pushSubscriptionId = "" ;
42+ private string _pushSubscriptionId = "— " ;
4343
4444 [ ObservableProperty ]
4545 private bool _isPushEnabled ;
@@ -106,12 +106,18 @@ public AppViewModel(PreferencesService prefs, OneSignalApiService apiService)
106106 }
107107
108108 private static string MaskValue ( string value ) =>
109- string . IsNullOrEmpty ( value ) ? value : new string ( '\u2022 ' , value . Length ) ;
109+ IsE2EMode && value != "—" ? new string ( '\u2022 ' , value . Length ) : value ;
110+
111+ private static string MaskPushId ( string ? value , bool hasNotificationPermission ) =>
112+ hasNotificationPermission ? MaskValue ( string . IsNullOrEmpty ( value ) ? "—" : value ) : "—" ;
113+
114+ private static string FormatToken ( string ? value ) =>
115+ string . IsNullOrEmpty ( value ) ? "null" : $ "{ value [ ..Math . Min ( 8 , value . Length ) ] } ...";
110116
111117 public async Task LoadInitialStateAsync ( )
112118 {
113119 var rawAppId = _apiService . GetAppId ( ) ;
114- AppId = IsE2EMode ? MaskValue ( rawAppId ) : rawAppId ;
120+ AppId = MaskValue ( rawAppId ) ;
115121 ConsentRequired = _prefs . ConsentRequired ;
116122 PrivacyConsentGiven = _prefs . PrivacyConsent ;
117123 InAppMessagesPaused = OneSignal . InAppMessages . Paused ;
@@ -121,8 +127,8 @@ public async Task LoadInitialStateAsync()
121127 var extId = OneSignal . User . ExternalId ?? _prefs . ExternalUserId ;
122128 UpdateUserStatus ( extId ) ;
123129
124- var rawPushId = OneSignal . User . PushSubscription . Id ?? "" ;
125- PushSubscriptionId = IsE2EMode ? MaskValue ( rawPushId ) : rawPushId ;
130+ var rawPushId = OneSignal . User . PushSubscription . Id ;
131+ PushSubscriptionId = MaskPushId ( rawPushId , HasNotificationPermission ) ;
126132 IsPushEnabled = OneSignal . User . PushSubscription . OptedIn ;
127133
128134 var onesignalId = OneSignal . User . OneSignalId ;
@@ -146,7 +152,7 @@ private void UpdateUserStatus(string? externalId)
146152 var loggedIn = ! string . IsNullOrEmpty ( externalId ) ;
147153 LoginButtonText = loggedIn ? "SWITCH USER" : "LOGIN USER" ;
148154 UserStatus = loggedIn ? "Logged In" : "Anonymous" ;
149- ExternalIdDisplay = loggedIn ? externalId ! : "– " ;
155+ ExternalIdDisplay = loggedIn ? externalId ! : "— " ;
150156 IsLoggedIn = loggedIn ;
151157 }
152158
@@ -598,10 +604,13 @@ private void OnPushSubscriptionChanged(object? sender, PushSubscriptionChangedEv
598604 {
599605 MainThread . BeginInvokeOnMainThread ( ( ) =>
600606 {
601- var rawPushId = OneSignal . User . PushSubscription . Id ?? "" ;
602- PushSubscriptionId = IsE2EMode ? MaskValue ( rawPushId ) : rawPushId ;
603- IsPushEnabled = OneSignal . User . PushSubscription . OptedIn ;
604- Debug . WriteLine ( $ "Push subscription changed: id={ rawPushId } , optedIn={ IsPushEnabled } ") ;
607+ var previous = args . State . Previous ;
608+ var current = args . State . Current ;
609+ PushSubscriptionId = MaskPushId ( current . Id , HasNotificationPermission ) ;
610+ IsPushEnabled = current . OptedIn ;
611+ Debug . WriteLine (
612+ $ "Push subscription changed: id={ previous . Id } -> { current . Id } , optedIn={ previous . OptedIn } -> { current . OptedIn } , token={ FormatToken ( previous . Token ) } -> { FormatToken ( current . Token ) } "
613+ ) ;
605614 } ) ;
606615 }
607616
@@ -613,6 +622,7 @@ OneSignalSDK.DotNet.Core.Notifications.NotificationPermissionChangedEventArgs ar
613622 MainThread . BeginInvokeOnMainThread ( ( ) =>
614623 {
615624 HasNotificationPermission = args . Permission ;
625+ PushSubscriptionId = MaskPushId ( OneSignal . User . PushSubscription . Id , HasNotificationPermission ) ;
616626 Debug . WriteLine ( $ "Permission changed: { args . Permission } ") ;
617627 } ) ;
618628 }
0 commit comments