@@ -18,6 +18,7 @@ class _MyAppState extends State<MyApp> {
1818 String ? _language;
1919 String ? _liveActivityId;
2020 bool _enableConsentButton = false ;
21+ bool _locationShared = false ;
2122
2223 // CHANGE THIS parameter to true if you want to test GDPR privacy consent
2324 bool _requireConsent = false ;
@@ -197,8 +198,20 @@ class _MyAppState extends State<MyApp> {
197198 }
198199
199200 void _handleSetLocationShared () {
200- print ("Setting location shared to true" );
201- OneSignal .Location .setShared (true );
201+ _locationShared = ! _locationShared;
202+ print ("Setting location shared to $_locationShared " );
203+ OneSignal .Location .setShared (_locationShared);
204+ setState (() {});
205+ }
206+
207+ void _handleRequestLocationPermission () {
208+ print ("Requesting location permission" );
209+ OneSignal .Location .requestPermission ();
210+ }
211+
212+ void _handleIsLocationShared () async {
213+ var isShared = await OneSignal .Location .isShared ();
214+ print ('Location shared: $isShared ' );
202215 }
203216
204217 void _handleGetExternalId () async {
@@ -394,9 +407,17 @@ class _MyAppState extends State<MyApp> {
394407 _enableConsentButton)
395408 ]),
396409 new TableRow (children: [
397- new OneSignalButton ("Set Location Shared" ,
410+ new OneSignalButton ("Location Shared: $ _locationShared " ,
398411 _handleSetLocationShared, ! _enableConsentButton)
399412 ]),
413+ new TableRow (children: [
414+ new OneSignalButton ("Request Location" ,
415+ _handleRequestLocationPermission, ! _enableConsentButton)
416+ ]),
417+ new TableRow (children: [
418+ new OneSignalButton ("Is Location Shared" ,
419+ _handleIsLocationShared, ! _enableConsentButton)
420+ ]),
400421 new TableRow (children: [
401422 new OneSignalButton (
402423 "Remove Tag" , _handleRemoveTag, ! _enableConsentButton)
0 commit comments