Skip to content

Commit eee32e4

Browse files
committed
Adding some testing methods in the dev app
1 parent 251b8f8 commit eee32e4

File tree

2 files changed

+39
-50
lines changed

2 files changed

+39
-50
lines changed

example/lib/main.dart

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
6969
});
7070
});
7171

72-
OneSignal.InAppMessages.paused(false);
73-
7472
OneSignal.InAppMessages
7573
.setInAppMessageClickedHandler((OSInAppMessageAction action) {
7674
this.setState(() {
@@ -120,19 +118,6 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
120118
print(stateChanges.jsonRepresentation());
121119
}
122120

123-
void _handleGetTags() {
124-
// OneSignal.shared.getTags().then((tags) {
125-
// if (tags == null) return;
126-
127-
// setState((() {
128-
// _debugLabelString = "$tags";
129-
// }));
130-
// }).catchError((error) {
131-
// setState(() {
132-
// _debugLabelString = "$error";
133-
// });
134-
// });
135-
}
136121

137122
void _handleSendTags() {
138123
print("Sending tags");
@@ -143,6 +128,14 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
143128
OneSignal.User.addTags(sendTags);
144129
}
145130

131+
void _handleRemoveTag() {
132+
print("Deleting tag");
133+
OneSignal.User.removeTag("test2");
134+
135+
print("Deleting tags array");
136+
OneSignal.User.removeTags(['test']);
137+
}
138+
146139
void _handlePromptForPushPermission() {
147140
print("Prompting for Permission");
148141
OneSignal.Notifications.requestPermission(true);
@@ -208,13 +201,7 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
208201
OneSignal.Location.setShared(true);
209202
}
210203

211-
void _handleRemoveTag() {
212-
print("Deleting tag");
213-
OneSignal.User.removeTag("test2");
214-
215-
print("Deleting tags array");
216-
OneSignal.User.removeTags(['test']);
217-
}
204+
218205

219206
void _handleSetExternalUserId() {
220207
print("Setting external user ID");
@@ -287,33 +274,35 @@ class _MyAppState extends State<MyApp> with OneSignalPushSubscriptionObserver {
287274
}
288275

289276
oneSignalInAppMessagingTriggerExamples() async {
290-
// /// Example addTrigger call for IAM
291-
// /// This will add 1 trigger so if there are any IAM satisfying it, it
292-
// /// will be shown to the user
293-
// OneSignal.shared.addTrigger("trigger_1", "one");
294-
295-
// /// Example addTriggers call for IAM
296-
// /// This will add 2 triggers so if there are any IAM satisfying these, they
297-
// /// will be shown to the user
298-
// Map<String, Object> triggers = new Map<String, Object>();
299-
// triggers["trigger_2"] = "two";
300-
// triggers["trigger_3"] = "three";
301-
// OneSignal.shared.addTriggers(triggers);
302-
303-
// // Removes a trigger by its key so if any future IAM are pulled with
304-
// // these triggers they will not be shown until the trigger is added back
305-
// OneSignal.shared.removeTriggerForKey("trigger_2");
306-
307-
// // Get the value for a trigger by its key
308-
// Object? triggerValue = await OneSignal.shared.getTriggerValueForKey("trigger_3");
309-
// print("'trigger_3' key trigger value: ${triggerValue?.toString()}");
310-
311-
// // Create a list and bulk remove triggers based on keys supplied
312-
// List<String> keys = ["trigger_1", "trigger_3"];
313-
// OneSignal.shared.removeTriggersForKeys(keys);
314-
315-
// // Toggle pausing (displaying or not) of IAMs
316-
// OneSignal.shared.pauseInAppMessages(false);
277+
/// Example addTrigger call for IAM
278+
/// This will add 1 trigger so if there are any IAM satisfying it, it
279+
/// will be shown to the user
280+
OneSignal.InAppMessages.addTrigger("trigger_1", "one");
281+
282+
/// Example addTriggers call for IAM
283+
/// This will add 2 triggers so if there are any IAM satisfying these, they
284+
/// will be shown to the user
285+
Map<String, Object> triggers = new Map<String, Object>();
286+
triggers["trigger_2"] = "two";
287+
triggers["trigger_3"] = "three";
288+
OneSignal.InAppMessages.addTriggers(triggers);
289+
290+
// Removes a trigger by its key so if any future IAM are pulled with
291+
// these triggers they will not be shown until the trigger is added back
292+
OneSignal.InAppMessages.removeTrigger("trigger_2");
293+
294+
295+
// Create a list and bulk remove triggers based on keys supplied
296+
List<String> keys = ["trigger_1", "trigger_3"];
297+
OneSignal.InAppMessages.removeTriggers(keys);
298+
299+
OneSignal.InAppMessages.clearTriggers();
300+
301+
// Toggle pausing (displaying or not) of IAMs
302+
OneSignal.InAppMessages.paused(false);
303+
var arePaused = await OneSignal.InAppMessages.arePaused();
304+
print('Notifications paused ${arePaused}');
305+
317306
}
318307

319308
oneSignalOutcomeExamples() async {

lib/src/inappmessages.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class OneSignalInAppMessages {
6363
}
6464

6565
/// Gets whether of not in app messages are paused
66-
Future<void> arePaused() async {
66+
Future<bool> arePaused() async {
6767
return await _channel.invokeMethod("OneSignal#arePaused");
6868
}
6969

0 commit comments

Comments
 (0)