@@ -38,28 +38,29 @@ class _MyAppState extends State<MyApp> {
38
38
39
39
OneSignal .shared
40
40
.setNotificationOpenedHandler ((OSNotificationOpenedResult result) {
41
- print ('NOTIFICATION OPENED HANDLER CALLED WITH: ${ result } ' );
42
- this .setState (() {
43
- _debugLabelString =
44
- "Opened notification: \n ${result .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
41
+ print ('NOTIFICATION OPENED HANDLER CALLED WITH: $result ' );
42
+ this .setState (() {
43
+ _debugLabelString =
44
+ "Opened notification: \n ${result .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
45
45
});
46
46
});
47
47
48
- OneSignal .shared
49
- .setNotificationWillShowInForegroundHandler ((OSNotificationReceivedEvent event) {
50
- print ('FOREGROUND HANDLER CALLED WITH: ${event }' );
51
- /// Display Notification, send null to not display
52
- event.complete (null );
53
-
54
- this .setState (() {
55
- _debugLabelString =
56
- "Notification received in foreground notification: \n ${event .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
48
+ OneSignal .shared.setNotificationWillShowInForegroundHandler (
49
+ (OSNotificationReceivedEvent event) {
50
+ print ('FOREGROUND HANDLER CALLED WITH: $event ' );
51
+
52
+ /// Display Notification, send null to not display
53
+ event.complete (null );
54
+
55
+ this .setState (() {
56
+ _debugLabelString =
57
+ "Notification received in foreground notification: \n ${event .notification .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
57
58
});
58
- });
59
+ });
59
60
60
61
OneSignal .shared
61
62
.setInAppMessageClickedHandler ((OSInAppMessageAction action) {
62
- this .setState (() {
63
+ this .setState (() {
63
64
_debugLabelString =
64
65
"In App Message Clicked: \n ${action .jsonRepresentation ().replaceAll ("\\ n" , "\n " )}" ;
65
66
});
@@ -79,8 +80,8 @@ class _MyAppState extends State<MyApp> {
79
80
print ("EMAIL SUBSCRIPTION STATE CHANGED ${changes .jsonRepresentation ()}" );
80
81
});
81
82
82
- OneSignal .shared. setSMSSubscriptionObserver (
83
- (OSSMSSubscriptionStateChanges changes) {
83
+ OneSignal .shared
84
+ . setSMSSubscriptionObserver ( (OSSMSSubscriptionStateChanges changes) {
84
85
print ("SMS SUBSCRIPTION STATE CHANGED ${changes .jsonRepresentation ()}" );
85
86
});
86
87
@@ -101,8 +102,7 @@ class _MyAppState extends State<MyApp> {
101
102
});
102
103
103
104
// NOTE: Replace with your own app ID from https://www.onesignal.com
104
- await OneSignal .shared
105
- .setAppId ("380dc082-5231-4cc2-ab51-a03da5a0e4c2" );
105
+ await OneSignal .shared.setAppId ("380dc082-5231-4cc2-ab51-a03da5a0e4c2" );
106
106
107
107
// iOS-only method to open launch URLs in Safari when set to false
108
108
OneSignal .shared.setLaunchURLsInApp (false );
@@ -121,13 +121,14 @@ class _MyAppState extends State<MyApp> {
121
121
// Some examples of how to use Outcome Events public methods with OneSignal SDK
122
122
oneSignalOutcomeEventsExamples ();
123
123
124
- bool userProvidedPrivacyConsent = await OneSignal .shared.userProvidedPrivacyConsent ();
124
+ bool userProvidedPrivacyConsent =
125
+ await OneSignal .shared.userProvidedPrivacyConsent ();
125
126
print ("USER PROVIDED PRIVACY CONSENT: $userProvidedPrivacyConsent " );
126
127
}
127
128
128
129
void _handleGetTags () {
129
130
OneSignal .shared.getTags ().then ((tags) {
130
- if (tags == null ) return ;
131
+ if (tags.isEmpty ) return ;
131
132
132
133
setState ((() {
133
134
_debugLabelString = "$tags " ;
@@ -168,7 +169,8 @@ class _MyAppState extends State<MyApp> {
168
169
OneSignal .shared.getDeviceState ().then ((deviceState) {
169
170
print ("DeviceState: ${deviceState ?.jsonRepresentation ()}" );
170
171
this .setState (() {
171
- _debugLabelString = deviceState? .jsonRepresentation () ?? "Device state null" ;
172
+ _debugLabelString =
173
+ deviceState? .jsonRepresentation () ?? "Device state null" ;
172
174
});
173
175
});
174
176
}
@@ -207,7 +209,7 @@ class _MyAppState extends State<MyApp> {
207
209
});
208
210
}
209
211
210
- void _handleSetSMSNumber () {
212
+ void _handleSetSMSNumber () {
211
213
if (_smsNumber == null ) return ;
212
214
213
215
print ("Setting SMS Number" );
@@ -265,29 +267,28 @@ class _MyAppState extends State<MyApp> {
265
267
if (_externalUserId == null ) return ;
266
268
267
269
OneSignal .shared.setExternalUserId (_externalUserId! ).then ((results) {
268
- if (results == null ) return ;
270
+ if (results.isEmpty ) return ;
269
271
270
- this .setState (() {
271
- _debugLabelString = "External user id set: $results " ;
272
- });
272
+ this .setState (() {
273
+ _debugLabelString = "External user id set: $results " ;
274
+ });
273
275
});
274
276
}
275
277
276
278
void _handleRemoveExternalUserId () {
277
279
OneSignal .shared.removeExternalUserId ().then ((results) {
278
- if (results == null ) return ;
280
+ if (results.isEmpty ) return ;
279
281
280
- this .setState (() {
281
- _debugLabelString = "External user id removed: $results " ;
282
- });
282
+ this .setState (() {
283
+ _debugLabelString = "External user id removed: $results " ;
284
+ });
283
285
});
284
286
}
285
287
286
288
void _handleSendNotification () async {
287
289
var deviceState = await OneSignal .shared.getDeviceState ();
288
290
289
- if (deviceState == null || deviceState.userId == null )
290
- return ;
291
+ if (deviceState == null || deviceState.userId == null ) return ;
291
292
292
293
var playerId = deviceState.userId! ;
293
294
@@ -315,8 +316,7 @@ class _MyAppState extends State<MyApp> {
315
316
void _handleSendSilentNotification () async {
316
317
var deviceState = await OneSignal .shared.getDeviceState ();
317
318
318
- if (deviceState == null || deviceState.userId == null )
319
- return ;
319
+ if (deviceState == null || deviceState.userId == null ) return ;
320
320
321
321
var playerId = deviceState.userId! ;
322
322
@@ -349,7 +349,8 @@ class _MyAppState extends State<MyApp> {
349
349
OneSignal .shared.removeTriggerForKey ("trigger_2" );
350
350
351
351
// Get the value for a trigger by its key
352
- Object ? triggerValue = await OneSignal .shared.getTriggerValueForKey ("trigger_3" );
352
+ Object ? triggerValue =
353
+ await OneSignal .shared.getTriggerValueForKey ("trigger_3" );
353
354
print ("'trigger_3' key trigger value: ${triggerValue ?.toString ()}" );
354
355
355
356
// Create a list and bulk remove triggers based on keys supplied
@@ -384,8 +385,8 @@ class _MyAppState extends State<MyApp> {
384
385
}
385
386
386
387
Future <void > outcomeAwaitExample () async {
387
- var outcomeEvent = await OneSignal .shared.sendOutcome ("await_normal_1" );
388
- print (outcomeEvent.jsonRepresentation ());
388
+ var outcomeEvent = await OneSignal .shared.sendOutcome ("await_normal_1" );
389
+ print (outcomeEvent.jsonRepresentation ());
389
390
}
390
391
391
392
@override
@@ -414,10 +415,8 @@ class _MyAppState extends State<MyApp> {
414
415
_handlePromptForPushPermission, ! _enableConsentButton)
415
416
]),
416
417
new TableRow (children: [
417
- new OneSignalButton (
418
- "Print Device State" ,
419
- _handleGetDeviceState,
420
- ! _enableConsentButton)
418
+ new OneSignalButton ("Print Device State" ,
419
+ _handleGetDeviceState, ! _enableConsentButton)
421
420
]),
422
421
new TableRow (children: [
423
422
new TextField (
@@ -468,12 +467,12 @@ class _MyAppState extends State<MyApp> {
468
467
)
469
468
]),
470
469
new TableRow (children: [
471
- new OneSignalButton (
472
- "Set SMS Number" , _handleSetSMSNumber, ! _enableConsentButton)
470
+ new OneSignalButton ("Set SMS Number" , _handleSetSMSNumber,
471
+ ! _enableConsentButton)
473
472
]),
474
473
new TableRow (children: [
475
- new OneSignalButton ("Logout SMS Number" , _handleLogoutSMSNumber,
476
- ! _enableConsentButton)
474
+ new OneSignalButton ("Logout SMS Number" ,
475
+ _handleLogoutSMSNumber, ! _enableConsentButton)
477
476
]),
478
477
new TableRow (children: [
479
478
new OneSignalButton ("Provide GDPR Consent" , _handleConsent,
@@ -516,12 +515,12 @@ class _MyAppState extends State<MyApp> {
516
515
)
517
516
]),
518
517
new TableRow (children: [
519
- new OneSignalButton (
520
- "Set External User ID" , _handleSetExternalUserId, ! _enableConsentButton)
518
+ new OneSignalButton ("Set External User ID" ,
519
+ _handleSetExternalUserId, ! _enableConsentButton)
521
520
]),
522
521
new TableRow (children: [
523
- new OneSignalButton (
524
- "Remove External User ID" , _handleRemoveExternalUserId, ! _enableConsentButton)
522
+ new OneSignalButton ("Remove External User ID" ,
523
+ _handleRemoveExternalUserId, ! _enableConsentButton)
525
524
]),
526
525
new TableRow (children: [
527
526
new TextField (
@@ -544,8 +543,8 @@ class _MyAppState extends State<MyApp> {
544
543
)
545
544
]),
546
545
new TableRow (children: [
547
- new OneSignalButton (
548
- "Set Language" , _handleSetLanguage, ! _enableConsentButton)
546
+ new OneSignalButton ("Set Language" , _handleSetLanguage,
547
+ ! _enableConsentButton)
549
548
]),
550
549
new TableRow (children: [
551
550
new Container (
0 commit comments