@@ -32,7 +32,7 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
32
32
Future <void > initPlatformState () async {
33
33
if (! mounted) return ;
34
34
35
- OneSignal .Debug .setLogLevel (OSLogLevel .debug );
35
+ OneSignal .Debug .setLogLevel (OSLogLevel .none );
36
36
37
37
OneSignal .Debug .setAlertLevel (OSLogLevel .none);
38
38
@@ -48,30 +48,31 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
48
48
49
49
// OneSignal.shared.setRequiresUserPrivacyConsent(_requireConsent);
50
50
51
- OneSignal .Notifications
52
- . setNotificationOpenedHandler ( (OSNotificationOpenedResult result) {
53
- print ('NOTIFICATION OPENED HANDLER CALLED WITH: ${result }' );
54
- this .setState (() {
55
- _debugLabelString =
56
- "Opened notification: \n ${result .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
51
+ OneSignal .Notifications . setNotificationOpenedHandler (
52
+ (OSNotificationOpenedResult result) {
53
+ print ('NOTIFICATION OPENED HANDLER CALLED WITH: ${result }' );
54
+ this .setState (() {
55
+ _debugLabelString =
56
+ "Opened notification: \n ${result .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
57
57
});
58
58
});
59
59
60
- OneSignal .Notifications
61
- .setNotificationWillShowInForegroundHandler ((OSNotificationReceivedEvent event) {
62
- print ('FOREGROUND HANDLER CALLED WITH: ${event }' );
63
- /// Display Notification, send null to not display
64
- event.complete (null );
65
-
66
- this .setState (() {
67
- _debugLabelString =
68
- "Notification received in foreground notification: \n ${event .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
60
+ OneSignal .Notifications .setNotificationWillShowInForegroundHandler (
61
+ (OSNotificationReceivedEvent event) {
62
+ print ('FOREGROUND HANDLER CALLED WITH: ${event }' );
63
+
64
+ /// Display Notification, send null to not display
65
+ event.complete (null );
66
+
67
+ this .setState (() {
68
+ _debugLabelString =
69
+ "Notification received in foreground notification: \n ${event .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
69
70
});
70
- });
71
+ });
71
72
72
- OneSignal .InAppMessages
73
- . setInAppMessageClickedHandler ( (OSInAppMessageAction action) {
74
- this .setState (() {
73
+ OneSignal .InAppMessages . setInAppMessageClickedHandler (
74
+ (OSInAppMessageAction action) {
75
+ this .setState (() {
75
76
_debugLabelString =
76
77
"In App Message Clicked: \n ${action .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
77
78
});
@@ -114,11 +115,11 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
114
115
// print("USER PROVIDED PRIVACY CONSENT: $userProvidedPrivacyConsent");
115
116
}
116
117
117
- void onOSPushSubscriptionChangedWithStateChanges (OSPushSubscriptionStateChanges stateChanges) {
118
+ void onOSPushSubscriptionChangedWithStateChanges (
119
+ OSPushSubscriptionStateChanges stateChanges) {
118
120
print (stateChanges.jsonRepresentation ());
119
121
}
120
122
121
-
122
123
void _handleSendTags () {
123
124
print ("Sending tags" );
124
125
OneSignal .User .addTagWithKey ("test2" , "val2" );
@@ -151,7 +152,7 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
151
152
// });
152
153
}
153
154
154
- void _handleSetLanguage () {
155
+ void _handleSetLanguage () {
155
156
if (_language == null ) return ;
156
157
print ("Setting language" );
157
158
OneSignal .User .setLanguage (_language! );
@@ -160,7 +161,7 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
160
161
void _handleSetEmail () {
161
162
if (_emailAddress == null ) return ;
162
163
print ("Setting email" );
163
-
164
+
164
165
OneSignal .User .addEmail (_emailAddress! );
165
166
}
166
167
@@ -183,7 +184,6 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
183
184
print ("Remove smsNumber" );
184
185
185
186
OneSignal .User .removeSms (_smsNumber! );
186
-
187
187
}
188
188
189
189
void _handleConsent () {
@@ -201,8 +201,6 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
201
201
OneSignal .Location .setShared (true );
202
202
}
203
203
204
-
205
-
206
204
void _handleSetExternalUserId () {
207
205
print ("Setting external user ID" );
208
206
// if (_externalUserId == null) return;
@@ -291,7 +289,6 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
291
289
// these triggers they will not be shown until the trigger is added back
292
290
OneSignal .InAppMessages .removeTrigger ("trigger_2" );
293
291
294
-
295
292
// Create a list and bulk remove triggers based on keys supplied
296
293
List <String > keys = ["trigger_1" , "trigger_3" ];
297
294
OneSignal .InAppMessages .removeTriggers (keys);
@@ -302,11 +299,9 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
302
299
OneSignal .InAppMessages .paused (false );
303
300
var arePaused = await OneSignal .InAppMessages .arePaused ();
304
301
print ('Notifications paused ${arePaused }' );
305
-
306
302
}
307
303
308
304
oneSignalOutcomeExamples () async {
309
-
310
305
OneSignal .Session .addOutcome ("normal_1" );
311
306
OneSignal .Session .addOutcome ("normal_2" );
312
307
@@ -318,12 +313,12 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
318
313
}
319
314
320
315
void _handleOptIn () {
321
- OneSignal .User .pushSubscription.optIn ();
322
- }
316
+ OneSignal .User .pushSubscription.optIn ();
317
+ }
323
318
324
319
void _handleOptOut () {
325
320
OneSignal .User .pushSubscription.optOut ();
326
- }
321
+ }
327
322
328
323
@override
329
324
Widget build (BuildContext context) {
@@ -346,12 +341,12 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
346
341
new OneSignalButton ("Prompt for Push Permission" ,
347
342
_handlePromptForPushPermission, ! _enableConsentButton)
348
343
]),
349
- // new TableRow(children: [
350
- // new OneSignalButton(
351
- // "Print Device State",
352
- // _handleGetDeviceState,
353
- // !_enableConsentButton)
354
- // ]),
344
+ // new TableRow(children: [
345
+ // new OneSignalButton(
346
+ // "Print Device State",
347
+ // _handleGetDeviceState,
348
+ // !_enableConsentButton)
349
+ // ]),
355
350
new TableRow (children: [
356
351
new TextField (
357
352
textAlign: TextAlign .center,
@@ -401,17 +396,17 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
401
396
)
402
397
]),
403
398
new TableRow (children: [
404
- new OneSignalButton (
405
- "Set SMS Number" , _handleSetSMSNumber, ! _enableConsentButton)
399
+ new OneSignalButton ("Set SMS Number" , _handleSetSMSNumber,
400
+ ! _enableConsentButton)
406
401
]),
407
402
// new TableRow(children: [
408
403
// new OneSignalButton("Remove SMS Number", _handleRemoveSmsNumber,
409
404
// !_enableConsentButton)
410
405
// ]),
411
- // new TableRow(children: [
412
- // new OneSignalButton("Provide GDPR Consent", _handleConsent,
413
- // _enableConsentButton)
414
- // ]),
406
+ // new TableRow(children: [
407
+ // new OneSignalButton("Provide GDPR Consent", _handleConsent,
408
+ // _enableConsentButton)
409
+ // ]),
415
410
new TableRow (children: [
416
411
new OneSignalButton ("Set Location Shared" ,
417
412
_handleSetLocationShared, ! _enableConsentButton)
@@ -420,42 +415,42 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
420
415
new OneSignalButton (
421
416
"Remove Tag" , _handleRemoveTag, ! _enableConsentButton)
422
417
]),
423
- // new TableRow(children: [
424
- // new OneSignalButton("Post Notification",
425
- // _handleSendNotification, !_enableConsentButton)
426
- // ]),
427
- // new TableRow(children: [
428
- // new OneSignalButton("Post Silent Notification",
429
- // _handleSendSilentNotification, !_enableConsentButton)
430
- // ]),
431
- // new TableRow(children: [
432
- // new TextField(
433
- // textAlign: TextAlign.center,
434
- // decoration: InputDecoration(
435
- // hintText: "External User ID",
436
- // labelStyle: TextStyle(
437
- // color: Color.fromARGB(255, 212, 86, 83),
438
- // )),
439
- // onChanged: (text) {
440
- // this.setState(() {
441
- // _externalUserId = text == "" ? null : text;
442
- // });
443
- // },
444
- // )
445
- // ]),
446
- // new TableRow(children: [
447
- // Container(
448
- // height: 8.0,
449
- // )
450
- // ]),
451
- // new TableRow(children: [
452
- // new OneSignalButton(
453
- // "Set External User ID", _handleSetExternalUserId, !_enableConsentButton)
454
- // ]),
455
- // new TableRow(children: [
456
- // new OneSignalButton(
457
- // "Remove External User ID", _handleRemoveExternalUserId, !_enableConsentButton)
458
- // ]),
418
+ // new TableRow(children: [
419
+ // new OneSignalButton("Post Notification",
420
+ // _handleSendNotification, !_enableConsentButton)
421
+ // ]),
422
+ // new TableRow(children: [
423
+ // new OneSignalButton("Post Silent Notification",
424
+ // _handleSendSilentNotification, !_enableConsentButton)
425
+ // ]),
426
+ // new TableRow(children: [
427
+ // new TextField(
428
+ // textAlign: TextAlign.center,
429
+ // decoration: InputDecoration(
430
+ // hintText: "External User ID",
431
+ // labelStyle: TextStyle(
432
+ // color: Color.fromARGB(255, 212, 86, 83),
433
+ // )),
434
+ // onChanged: (text) {
435
+ // this.setState(() {
436
+ // _externalUserId = text == "" ? null : text;
437
+ // });
438
+ // },
439
+ // )
440
+ // ]),
441
+ // new TableRow(children: [
442
+ // Container(
443
+ // height: 8.0,
444
+ // )
445
+ // ]),
446
+ // new TableRow(children: [
447
+ // new OneSignalButton(
448
+ // "Set External User ID", _handleSetExternalUserId, !_enableConsentButton)
449
+ // ]),
450
+ // new TableRow(children: [
451
+ // new OneSignalButton(
452
+ // "Remove External User ID", _handleRemoveExternalUserId, !_enableConsentButton)
453
+ // ]),
459
454
new TableRow (children: [
460
455
new TextField (
461
456
textAlign: TextAlign .center,
@@ -477,8 +472,8 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
477
472
)
478
473
]),
479
474
new TableRow (children: [
480
- new OneSignalButton (
481
- "Set Language" , _handleSetLanguage, ! _enableConsentButton)
475
+ new OneSignalButton ("Set Language" , _handleSetLanguage,
476
+ ! _enableConsentButton)
482
477
]),
483
478
new TableRow (children: [
484
479
new Container (
@@ -523,10 +518,10 @@ class OneSignalButtonState extends State<OneSignalButton> {
523
518
new TableRow (children: [
524
519
new TextButton (
525
520
style: TextButton .styleFrom (
526
- foregroundColor: Colors .white,
521
+ foregroundColor: Colors .white,
527
522
disabledForegroundColor: Colors .white,
528
523
backgroundColor: Color .fromARGB (255 , 212 , 86 , 83 ),
529
- disabledBackgroundColor: Color .fromARGB (180 , 212 , 86 , 83 ),
524
+ disabledBackgroundColor: Color .fromARGB (180 , 212 , 86 , 83 ),
530
525
padding: EdgeInsets .all (8.0 ),
531
526
),
532
527
child: new Text (widget.title),
0 commit comments