• Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums

Award Achievement Issue

Scheduled Pinned Locked Moved Solved Cloud Code
cloud code scriptgamification
5 Posts 3 Posters 465 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Davis Knox
    wrote on last edited by
    #1

    Hi there,

    I am attempting to award some achievements via cloud code, and am running into an error that I can't seem to rectify with the existing documentation. I'm getting the error:

    "Script Error (Line 79, Column 0): Can't find method com.braincloud.core.service.scripting.proxy.GamificationServiceProxy.awardAchievements(object)."
    

    And code causing the error:

        // process achievements, put them both here so we only access proxy if we need it (for minimal api count)
        if( statTotalMeters+meters >= PERSISTANCE_TRAVEL_THRESHOLD ||
            statLandings+padsLanded >= SANCT_THRESHOLD)
        {
            var gamificationService = bridge.getGamificationServiceProxy();
            var achievementIds = [];
            if(statTotalMeters+meters >= PERSISTANCE_TRAVEL_THRESHOLD)
            {
                achievementIds.push(PERSISTANCE_ID);
            }
            if(statLandings+padsLanded >= SANCT_THRESHOLD)
            {
                achievementIds.push(SANCT_ID);
            }
            
            var achievementRes = gamificationService.awardAchievements(achievementIds)
        }
    

    Everything "feels" right but it's likely something silly I'm doing wrong?

    Thanks,
    Davis

    1 Reply Last reply
    0
  • JonathanJ Offline
    JonathanJ Offline
    Jonathan
    wrote on last edited by
    #2

    Your code looks good, but awardAchievements takes an extra boolean parameter in cloud code, includeMetaData, which controls if the extra achievement metadata is returned in the json response.

    var includeMetaData = false;
    var achievementRes = gamificationService.awardAchievements(achievementIds, includeMetaData);
    

    The documentation will be updated to show the missing value.

    Thanks for reporting the issue.

    1 Reply Last reply
    0
  • Paul WinterhalderP Online
    Paul WinterhalderP Online
    Paul Winterhalder brainCloudAdmin
    wrote on last edited by
    #3

    Hi David,

    Thanks for reporting this - it looks like the signature of that method changed over time, but we didn't update the cloud-code version of the call.

    The cloud-code version of that call requires an additional boolean parameter - "includeMetadata" - which determines how much data is returned in the result.

    If true, the result of awarding an achievement looks like this (we've since determined the client has likely retrieved/cached that extra data anyway, so there isn't normally a need to return it):

    {
        "data": {
            "achievements": [
                {
                    "extraData": null,
                    "googleAchievementId": null,
                    "achievementId": "EGG_ACH02",
                    "description": "You saved 10,000 Animals!",
                    "title": "Saviour",
                    "appleAchievementId": "",
                    "steamEnabled": false,
                    "fbGamePoints": 10,
                    "imageUrl": "https://internal.braincloudservers.com/files/portal/g/11281/metadata/achievements/EGG_ACH02.png",
                    "steamAchievementId": "",
                    "invisibleUntilEarned": false,
                    "fbEnabled": true,
                    "appleEnabled": false,
                    "googleEnabled": null,
                    "id": "EGG_ACH02",
                    "status": "AWARDED"
                }
            ]
        },
        "status": 200
    }
    

    if false - you just get the id and status of any achievements that are awarded.

    If the achievements had already been awarded, you'll get an empty array of achievements back.

    So anyway, try something like:

    var achievementRes = gamificationService.awardAchievements(achievementIds, false);
    

    and you should be good to go!

    Thanks again for reporting this - we'll get that fixed up (which will probably mean we'll add an additional cloud-code method with the proper signature. This method will continue to work though!)

    Cheers!

    Paul.

    1 Reply Last reply
    0
  • Paul WinterhalderP Online
    Paul WinterhalderP Online
    Paul Winterhalder brainCloudAdmin
    wrote on last edited by
    #4

    D'oh - dueling support team responses! 🙂

    1 Reply Last reply
    0
  • D Offline
    D Offline
    Davis Knox
    wrote on last edited by
    #5

    Cheers guys. Thanks for the quick response!

    1 Reply Last reply
    0

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users