Skip to content

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

FieldDescription
active_listArray of badges the user has earned
inactive_listArray of badges available but not yet earned
achivedTimeTimestamp when badge was earned (only in active_list)
activityNameInternal name of the badge activity
badgeUnique badge identifier
badgeDescDescription text for the badge
badgeImageBadge image dimensions/reference
campaignNameCampaign this badge belongs to
statusBadge status (1 = earned, 2 = available)
tagsArray of tags associated with the badge
titleDisplay title for the badge

Powered by Upshot.ai