Skip to content

Commit d553e73

Browse files
authored
Merge pull request #595 from OneSignal/workflows-for-everyone
Refinements to CI action
2 parents 1894976 + 9e69c69 commit d553e73

13 files changed

+212
-206
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
run: flutter pub get
2828

2929
- name: Static Analysis
30-
run: flutter analyze
30+
run: flutter analyze --no-pub --no-fatal-infos
3131

3232
- name: Ensure the Dart code is formatted correctly
33-
run: flutter format --set-exit-if-changed --dry-run .
33+
run: flutter format -o none --set-exit-if-changed .
3434

3535
- name: Run Flutter unit tests
3636
run: flutter test

example/lib/main.dart

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,29 @@ class _MyAppState extends State<MyApp> {
3838

3939
OneSignal.shared
4040
.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")}";
4545
});
4646
});
4747

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")}";
5758
});
58-
});
59+
});
5960

6061
OneSignal.shared
6162
.setInAppMessageClickedHandler((OSInAppMessageAction action) {
62-
this.setState(() {
63+
this.setState(() {
6364
_debugLabelString =
6465
"In App Message Clicked: \n${action.jsonRepresentation().replaceAll("\\n", "\n")}";
6566
});
@@ -79,8 +80,8 @@ class _MyAppState extends State<MyApp> {
7980
print("EMAIL SUBSCRIPTION STATE CHANGED ${changes.jsonRepresentation()}");
8081
});
8182

82-
OneSignal.shared.setSMSSubscriptionObserver(
83-
(OSSMSSubscriptionStateChanges changes) {
83+
OneSignal.shared
84+
.setSMSSubscriptionObserver((OSSMSSubscriptionStateChanges changes) {
8485
print("SMS SUBSCRIPTION STATE CHANGED ${changes.jsonRepresentation()}");
8586
});
8687

@@ -101,8 +102,7 @@ class _MyAppState extends State<MyApp> {
101102
});
102103

103104
// 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");
106106

107107
// iOS-only method to open launch URLs in Safari when set to false
108108
OneSignal.shared.setLaunchURLsInApp(false);
@@ -121,13 +121,14 @@ class _MyAppState extends State<MyApp> {
121121
// Some examples of how to use Outcome Events public methods with OneSignal SDK
122122
oneSignalOutcomeEventsExamples();
123123

124-
bool userProvidedPrivacyConsent = await OneSignal.shared.userProvidedPrivacyConsent();
124+
bool userProvidedPrivacyConsent =
125+
await OneSignal.shared.userProvidedPrivacyConsent();
125126
print("USER PROVIDED PRIVACY CONSENT: $userProvidedPrivacyConsent");
126127
}
127128

128129
void _handleGetTags() {
129130
OneSignal.shared.getTags().then((tags) {
130-
if (tags == null) return;
131+
if (tags.isEmpty) return;
131132

132133
setState((() {
133134
_debugLabelString = "$tags";
@@ -168,7 +169,8 @@ class _MyAppState extends State<MyApp> {
168169
OneSignal.shared.getDeviceState().then((deviceState) {
169170
print("DeviceState: ${deviceState?.jsonRepresentation()}");
170171
this.setState(() {
171-
_debugLabelString = deviceState?.jsonRepresentation() ?? "Device state null";
172+
_debugLabelString =
173+
deviceState?.jsonRepresentation() ?? "Device state null";
172174
});
173175
});
174176
}
@@ -207,7 +209,7 @@ class _MyAppState extends State<MyApp> {
207209
});
208210
}
209211

210-
void _handleSetSMSNumber() {
212+
void _handleSetSMSNumber() {
211213
if (_smsNumber == null) return;
212214

213215
print("Setting SMS Number");
@@ -265,29 +267,28 @@ class _MyAppState extends State<MyApp> {
265267
if (_externalUserId == null) return;
266268

267269
OneSignal.shared.setExternalUserId(_externalUserId!).then((results) {
268-
if (results == null) return;
270+
if (results.isEmpty) return;
269271

270-
this.setState(() {
271-
_debugLabelString = "External user id set: $results";
272-
});
272+
this.setState(() {
273+
_debugLabelString = "External user id set: $results";
274+
});
273275
});
274276
}
275277

276278
void _handleRemoveExternalUserId() {
277279
OneSignal.shared.removeExternalUserId().then((results) {
278-
if (results == null) return;
280+
if (results.isEmpty) return;
279281

280-
this.setState(() {
281-
_debugLabelString = "External user id removed: $results";
282-
});
282+
this.setState(() {
283+
_debugLabelString = "External user id removed: $results";
284+
});
283285
});
284286
}
285287

286288
void _handleSendNotification() async {
287289
var deviceState = await OneSignal.shared.getDeviceState();
288290

289-
if (deviceState == null || deviceState.userId == null)
290-
return;
291+
if (deviceState == null || deviceState.userId == null) return;
291292

292293
var playerId = deviceState.userId!;
293294

@@ -315,8 +316,7 @@ class _MyAppState extends State<MyApp> {
315316
void _handleSendSilentNotification() async {
316317
var deviceState = await OneSignal.shared.getDeviceState();
317318

318-
if (deviceState == null || deviceState.userId == null)
319-
return;
319+
if (deviceState == null || deviceState.userId == null) return;
320320

321321
var playerId = deviceState.userId!;
322322

@@ -349,7 +349,8 @@ class _MyAppState extends State<MyApp> {
349349
OneSignal.shared.removeTriggerForKey("trigger_2");
350350

351351
// 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");
353354
print("'trigger_3' key trigger value: ${triggerValue?.toString()}");
354355

355356
// Create a list and bulk remove triggers based on keys supplied
@@ -384,8 +385,8 @@ class _MyAppState extends State<MyApp> {
384385
}
385386

386387
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());
389390
}
390391

391392
@override
@@ -414,10 +415,8 @@ class _MyAppState extends State<MyApp> {
414415
_handlePromptForPushPermission, !_enableConsentButton)
415416
]),
416417
new TableRow(children: [
417-
new OneSignalButton(
418-
"Print Device State",
419-
_handleGetDeviceState,
420-
!_enableConsentButton)
418+
new OneSignalButton("Print Device State",
419+
_handleGetDeviceState, !_enableConsentButton)
421420
]),
422421
new TableRow(children: [
423422
new TextField(
@@ -468,12 +467,12 @@ class _MyAppState extends State<MyApp> {
468467
)
469468
]),
470469
new TableRow(children: [
471-
new OneSignalButton(
472-
"Set SMS Number", _handleSetSMSNumber, !_enableConsentButton)
470+
new OneSignalButton("Set SMS Number", _handleSetSMSNumber,
471+
!_enableConsentButton)
473472
]),
474473
new TableRow(children: [
475-
new OneSignalButton("Logout SMS Number", _handleLogoutSMSNumber,
476-
!_enableConsentButton)
474+
new OneSignalButton("Logout SMS Number",
475+
_handleLogoutSMSNumber, !_enableConsentButton)
477476
]),
478477
new TableRow(children: [
479478
new OneSignalButton("Provide GDPR Consent", _handleConsent,
@@ -516,12 +515,12 @@ class _MyAppState extends State<MyApp> {
516515
)
517516
]),
518517
new TableRow(children: [
519-
new OneSignalButton(
520-
"Set External User ID", _handleSetExternalUserId, !_enableConsentButton)
518+
new OneSignalButton("Set External User ID",
519+
_handleSetExternalUserId, !_enableConsentButton)
521520
]),
522521
new TableRow(children: [
523-
new OneSignalButton(
524-
"Remove External User ID", _handleRemoveExternalUserId, !_enableConsentButton)
522+
new OneSignalButton("Remove External User ID",
523+
_handleRemoveExternalUserId, !_enableConsentButton)
525524
]),
526525
new TableRow(children: [
527526
new TextField(
@@ -544,8 +543,8 @@ class _MyAppState extends State<MyApp> {
544543
)
545544
]),
546545
new TableRow(children: [
547-
new OneSignalButton(
548-
"Set Language", _handleSetLanguage, !_enableConsentButton)
546+
new OneSignalButton("Set Language", _handleSetLanguage,
547+
!_enableConsentButton)
549548
]),
550549
new TableRow(children: [
551550
new Container(

0 commit comments

Comments
 (0)