Appearance
User Badges
User badges are achievements that users can earn by completing specific actions or reaching milestones in your Flutter app. They provide gamification and encourage user engagement.
Overview
The user badges system allows you to:
- Award badges for user achievements
- Track badge progress
- Display earned and available badges
- Motivate users with visual rewards
- Create custom badge campaigns
How to Fetch User Badges
Request user badges data:
dart
FlutterUpshotPlugin.fetchUserBadges();
// Fetch user badges
static const _channel = MethodChannel('flutter_upshot_plugin');
UpshotMethodChannel() {
_channel.setMethodCallHandler (_methodCallHandler);
}
Future <dynamic>_methodCallHandler(MethodCall call) async {
if (call.method == 'upshotBadgesData ') {
Map data = call.arguments as Map;
}
}
Response Structure
The user badges response contains two main arrays:
Active List (Earned Badges) Badges that the user has already earned:
json
{
"active_list": [
{
"achivedTime": 1493892162263,
"activityName": "Badge1",
"badge": "590c28142b2f15cf1b7b23d3590c39c12b2f15a7517b23c9",
"badgeDesc": "YOU HAVE WON A FREE PIZZA FROM US :)",
"badgeImage": "{128, 128}",
"campaignName": "Campaign1",
"status": 1,
"tags": ["Welcome"],
"title": "CONGRATULATIONS!!!"
}
]
}
Inactive List (Available Badges) Badges that are available but not yet earned:
json
{
"inactive_list": [
{
"activityName": "Badge2",
"badge": "590c397c2b2f15a9517b23c6590c3e5a2b2f152b5a7b23cc",
"badgeDesc": "You have received two free movie tickets! To accept them, please click the okay button.",
"badgeImage": "{128, 128}",
"campaignName": "Campaign2",
"status": 2,
"tags": ["Welcome"],
"title": "Dear Customer!!!"
}
]
}
Response Field Descriptions
Field | Description |
---|---|
active_list | Array of badges the user has earned |
inactive_list | Array of badges available but not yet earned |
achivedTime | Timestamp when badge was earned (only in active_list) |
activityName | Internal name of the badge activity |
badge | Unique badge identifier |
badgeDesc | Description text for the badge |
badgeImage | Badge image dimensions/reference |
campaignName | Campaign this badge belongs to |
status | Badge status (1 = earned, 2 = available) |
tags | Array of tags associated with the badge |
title | Display title for the badge |