Skip to content

Commit 0d48785

Browse files
committed
Disable Demo Buttons if Consent Required
• Improved the demo to disable most buttons (except the provide consent button) if the developer wants to test GDPR/privacy consent
1 parent d66a192 commit 0d48785

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

example/lib/main.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class _MyAppState extends State<MyApp> {
1717
bool _enableConsentButton = false;
1818

1919
// CHANGE THIS parameter to true if you want to test GDPR privacy consent
20-
bool requireConsent = false;
20+
bool _requireConsent = true;
2121

2222
@override
2323
void initState() {
@@ -31,7 +31,7 @@ class _MyAppState extends State<MyApp> {
3131

3232
OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.none);
3333

34-
OneSignal.shared.setRequiresUserPrivacyConsent(requireConsent);
34+
OneSignal.shared.setRequiresUserPrivacyConsent(_requireConsent);
3535

3636
var settings = {
3737
OSiOSSettings.autoPrompt : false,
@@ -62,7 +62,7 @@ class _MyAppState extends State<MyApp> {
6262
print("EMAIL SUBSCRIPTION STATE CHANGED ${changes.jsonRepresentation()}");
6363
});
6464

65-
await OneSignal.shared.init("b2f7f966-d8cc-11e4-bed1-df8f05be55ba", iOSSettings: settings);
65+
await OneSignal.shared.init("78e8aff3-7ce2-401f-9da0-2d41f287ebaf", iOSSettings: settings);
6666

6767
OneSignal.shared.setInFocusDisplayType(OSNotificationDisplayType.notification);
6868

@@ -213,22 +213,22 @@ class _MyAppState extends State<MyApp> {
213213
children: [
214214
new TableRow(
215215
children: [
216-
new OneSignalButton("Get Tags", _handleGetTags, true)
216+
new OneSignalButton("Get Tags", _handleGetTags, !_enableConsentButton)
217217
]
218218
),
219219
new TableRow(
220220
children: [
221-
new OneSignalButton("Send Tags", _handleSendTags, true)
221+
new OneSignalButton("Send Tags", _handleSendTags, !_enableConsentButton)
222222
]
223223
),
224224
new TableRow(
225225
children: [
226-
new OneSignalButton("Prompt for Push Permission", _handlePromptForPushPermission, true)
226+
new OneSignalButton("Prompt for Push Permission", _handlePromptForPushPermission, !_enableConsentButton)
227227
]
228228
),
229229
new TableRow(
230230
children: [
231-
new OneSignalButton("Print Permission Subscription State", _handleGetPermissionSubscriptionState, true)
231+
new OneSignalButton("Print Permission Subscription State", _handleGetPermissionSubscriptionState, !_enableConsentButton)
232232
]
233233
),
234234
new TableRow(
@@ -258,12 +258,12 @@ class _MyAppState extends State<MyApp> {
258258
),
259259
new TableRow(
260260
children: [
261-
new OneSignalButton("Set Email", _handleSetEmail, true)
261+
new OneSignalButton("Set Email", _handleSetEmail, !_enableConsentButton)
262262
]
263263
),
264264
new TableRow(
265265
children: [
266-
new OneSignalButton("Logout Email", _handleLogoutEmail, true)
266+
new OneSignalButton("Logout Email", _handleLogoutEmail, !_enableConsentButton)
267267
]
268268
),
269269
new TableRow(
@@ -273,22 +273,22 @@ class _MyAppState extends State<MyApp> {
273273
),
274274
new TableRow(
275275
children: [
276-
new OneSignalButton("Set Location Shared", _handleSetLocationShared, true)
276+
new OneSignalButton("Set Location Shared", _handleSetLocationShared, !_enableConsentButton)
277277
]
278278
),
279279
new TableRow(
280280
children: [
281-
new OneSignalButton("Delete Tag", _handleDeleteTag, true)
281+
new OneSignalButton("Delete Tag", _handleDeleteTag, !_enableConsentButton)
282282
]
283283
),
284284
new TableRow(
285285
children: [
286-
new OneSignalButton("Post Notification", _handleSendNotification, true)
286+
new OneSignalButton("Post Notification", _handleSendNotification, !_enableConsentButton)
287287
]
288288
),
289289
new TableRow(
290290
children: [
291-
new OneSignalButton("Post Silent Notification", _handleSendSilentNotification, true)
291+
new OneSignalButton("Post Silent Notification", _handleSendSilentNotification, !_enableConsentButton)
292292
]
293293
),
294294
new TableRow(

0 commit comments

Comments
 (0)