When you send custom events with attributes from the Pushwoosh Flutter SDK, the attribute data types are resolved as follows.
1. Define events in the Control Panel (recommended)
Create the event and its attributes, with their types, in the Pushwoosh Control Panel first (your application → Events). For example "isSubscribed" as Boolean, "itemCount" as Integer.
2. Send the event from Flutter
Use the instance accessor Pushwoosh.getInstance and pass the attributes as a positional Map<String, dynamic>:
await Pushwoosh.getInstance.postEvent("myCustomEvent", {
"productName": "Example Item", // String
"quantity": 2, // Integer
"isAvailable": true, // Boolean
"tags": ["new", "featured"] // List of Strings
});
The SDK infers each attribute's type from the native Dart value you pass. You do not pass an explicit type field per attribute, unlike some raw API examples.
Tags work the same way:
await Pushwoosh.getInstance.setTags({
"username": "john_doe",
"age": 25,
"interests": ["sports", "tech"]
});
3. Automatic event and attribute creation
If you post an event that is not yet defined in the Control Panel, Pushwoosh creates the event and its attributes automatically. Types are inferred from the values in the first postEvent call, so {"myAttribute": true} becomes Boolean and {"myAttribute": 1} becomes Integer.
4. Correcting a wrong attribute type
You cannot change the type of an existing attribute of an existing event. To fix it:
- Delete the auto-created event definition in the Control Panel (only if losing its historical structure is acceptable), then re-create it manually with the correct attribute types; or
- Use a new event name and make sure the first
postEventcall sends correctly typed Dart values.
Pre-defining the event and its attribute types in the Control Panel before sending any data is the most reliable approach.
Comments
0 comments
Please sign in to leave a comment.