File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ class AppViewModel extends ChangeNotifier {
6464
6565 bool get isLoggedIn => _externalUserId != null ;
6666
67+ String ? _oneSignalId;
68+ String ? get oneSignalId => _oneSignalId;
69+
6770 // Push state
6871 String ? _pushSubscriptionId;
6972 String ? get pushSubscriptionId => _pushSubscriptionId;
@@ -139,9 +142,11 @@ class AppViewModel extends ChangeNotifier {
139142 _pushEnabled = OneSignal .User .pushSubscription.optedIn ?? false ;
140143 _hasNotificationPermission = OneSignal .Notifications .permission;
141144
145+ final onesignalId = await OneSignal .User .getOnesignalId ();
146+ _oneSignalId = onesignalId;
147+
142148 notifyListeners ();
143149
144- final onesignalId = await OneSignal .User .getOnesignalId ();
145150 if (onesignalId == null ) return ;
146151
147152 // fetchUserDataFromApi owns _isLoading + notifyListeners.
@@ -171,6 +176,9 @@ class AppViewModel extends ChangeNotifier {
171176 'User changed: onesignalId=${nextOnesignalId ?? 'null' }, externalId=${state .current .externalId ?? 'null' }' ,
172177 );
173178
179+ _oneSignalId = nextOnesignalId;
180+ notifyListeners ();
181+
174182 // Drive the post-login fetch from the observer so it runs only once the
175183 // SDK has actually assigned a new onesignalId. Logout clears it to null;
176184 // skip the fetch in that case (logoutUser already clears local lists).
Original file line number Diff line number Diff line change @@ -28,6 +28,29 @@ class PushSection extends StatelessWidget {
2828 padding: AppSpacing .cardPadding,
2929 child: Column (
3030 children: [
31+ Row (
32+ children: [
33+ Text (
34+ 'OneSignal ID' ,
35+ style: Theme .of (context).textTheme.bodyMedium,
36+ ),
37+ const SizedBox (width: 12 ),
38+ Expanded (
39+ child: Semantics (
40+ identifier: 'onesignal_id_value' ,
41+ container: true ,
42+ child: SelectableText (
43+ vm.oneSignalId ?? '—' ,
44+ style: Theme .of (context).textTheme.bodySmall? .copyWith (
45+ fontFamily: 'monospace' ,
46+ ),
47+ textAlign: TextAlign .end,
48+ ),
49+ ),
50+ ),
51+ ],
52+ ),
53+ const Divider (),
3154 Row (
3255 children: [
3356 Text (
Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ class AppViewModel extends ChangeNotifier {
5959
6060 bool get isLoggedIn => _externalUserId != null ;
6161
62+ String ? _oneSignalId;
63+ String ? get oneSignalId => _oneSignalId;
64+
6265 // Push state
6366 String ? _pushSubscriptionId;
6467 String ? get pushSubscriptionId => _pushSubscriptionId;
@@ -134,9 +137,11 @@ class AppViewModel extends ChangeNotifier {
134137 _pushEnabled = OneSignal .User .pushSubscription.optedIn ?? false ;
135138 _hasNotificationPermission = OneSignal .Notifications .permission;
136139
140+ final onesignalId = await OneSignal .User .getOnesignalId ();
141+ _oneSignalId = onesignalId;
142+
137143 notifyListeners ();
138144
139- final onesignalId = await OneSignal .User .getOnesignalId ();
140145 if (onesignalId == null ) return ;
141146
142147 _isLoading = true ;
@@ -172,6 +177,8 @@ class AppViewModel extends ChangeNotifier {
172177 debugPrint (
173178 'User changed: onesignalId=${state .current .onesignalId ?? 'null' }, externalId=${state .current .externalId ?? 'null' }' ,
174179 );
180+ _oneSignalId = state.current.onesignalId;
181+ notifyListeners ();
175182 });
176183 }
177184
Original file line number Diff line number Diff line change @@ -28,6 +28,29 @@ class PushSection extends StatelessWidget {
2828 padding: AppSpacing .cardPadding,
2929 child: Column (
3030 children: [
31+ Row (
32+ children: [
33+ Text (
34+ 'OneSignal ID' ,
35+ style: Theme .of (context).textTheme.bodyMedium,
36+ ),
37+ const SizedBox (width: 12 ),
38+ Expanded (
39+ child: Semantics (
40+ identifier: 'onesignal_id_value' ,
41+ container: true ,
42+ child: SelectableText (
43+ vm.oneSignalId ?? '—' ,
44+ style: Theme .of (context).textTheme.bodySmall? .copyWith (
45+ fontFamily: 'monospace' ,
46+ ),
47+ textAlign: TextAlign .end,
48+ ),
49+ ),
50+ ),
51+ ],
52+ ),
53+ const Divider (),
3154 Row (
3255 children: [
3356 Text (
You can’t perform that action at this time.
0 commit comments