• 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
J

JasonL

@JasonL
bitHeads
About
Posts
51
Topics
0
Groups
3
Followers
0
Following
0

Posts

Recent Best Controversial

    Discussion - Promotions
  • J JasonL

    @francesco-lenolli
    For both of your questions, a single call -- GetEligiblePromotions() will do the work. It will return the values of maxPurchases and the caller's purchased, as well as the Unix timestamps for triggeredForUserAt and 'expiresForUserAt` for automated promotions.
    8b4d83d1-13cd-428c-a15f-04253dc98a5c-image.png


  • Discussion - Promotions
  • J JasonL

    @francesco-lenolli
    Could you specify which part you are still confused about?


  • Discussion - Promotions
  • J JasonL

    @francesco-lenolli
    Excellent observation! You are correct. Our server-side validation was set to filter out any duration above 596 hours and mark it as "expired". However, we have thoroughly reviewed this validation and have since removed it. This patch will be deployed to our server today, meaning a duration limit will no longer exist. We appreciate you bringing this to our attention. Thank you.


  • Discussion - Promotions
  • J JasonL

    Make sure you have enabled that promotion, can you provide us with your AppId and that automated promotionId?


  • Repeat push notification schedule
  • J JasonL

    You can schedule a cloud code script to run at a specific target time (as shown in the example below, which will execute at 23:59 every day), instead of adding a certain amount of time to the script's execution time.

    "use strict";
    
    function main() {
        var response = {}
    
        bridge.logDebugJson("Script Inputs", data)
    
        const scriptName = data.scriptName
        const interval = data.args.interval
        const searchSpan = interval < 60 ? 60 : 60 * 24
    
        // schedule checking and re-schedule itself for the next week at 23:59 on the same day
        var scriptProxy = bridge.getScriptServiceProxy()
    
        var dateTimeSpanMinsFromNowInMillis = new Date().getTime() + (searchSpan * 60 * 1000)
        var result = scriptProxy.getScheduledCloudScripts(dateTimeSpanMinsFromNowInMillis)
    
        var nowTime = new Date().getTime()
    
        if ((result.status == 200) && (result.data !== null)) {
            for (var i = 0; i < result.data.scheduledJobs.length; i++) {
                if (result.data.scheduledJobs[i].scriptName === scriptName && result.data.scheduledJobs[i].scheduledStartTime > nowTime) {
                    scriptProxy.cancelScheduledScript(result.data.scheduledJobs[i].jobId)
                }
            }
        }
    
        const targetHour = 23
        const targetMinute = 59
        const minutesDifference = getMinutesDifference(targetHour, targetMinute)
        let minutesFromNow = minutesDifference + interval
        bridge.logInfo(`minutesFromNow between the script calling time and the time of 23:59 on a same day${minutesFromNow}`)
        response.scheduleJob = scriptProxy.scheduleRunScriptMinutes(scriptName, data, minutesFromNow)
    
        // the code for your script 
    
        return response
    }
    
    function getMinutesDifference(targetHour, targetMinute) {
        const now = new Date()
        const targetTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), targetHour, targetMinute)
        const differenceInMilliseconds = targetTime - now
        bridge.logInfo(`differenceInMilliseconds between the script calling time and the target time: ${differenceInMilliseconds}`)
        const differenceInMinutes = Math.floor(differenceInMilliseconds / (1000 * 60))
        return differenceInMinutes
    }
    
    main()
    

    The parameters for this script will be 1440 minutes,

    {
      "scriptName": "thisScriptNameItself",
      "args": {
        "interval": 1440
      }
    }
    

  • RelayService.Send not working and get disconnect error
  • J JasonL

    No problem! glad to hear that.


  • RelayService.Send not working and get disconnect error
  • J JasonL

    Could you zip your project files to Google Drive and share them with us?


  • RelayService.Send not working and get disconnect error
  • J JasonL

    Please refer to this article for the details of those settings on the server configuration page -- https://help.getbraincloud.com/en/articles/9153860-design-servers-my-servers
    image.png


  • RelayService.Send not working and get disconnect error
  • J JasonL

    It looks like you have configured the Max Session Time to be 5 minutes, which aligns with the logs. You can extend this time to a longer duration.
    image.png


  • Virtual Purchase
  • J JasonL

    The SysRecordTransaction method should work for your needs. Refer to the provided link for more information -- https://docs-internal.braincloudservers.com/api/capi/appstore/sysrecordtransaction


  • Post Score when a Tournament ends?
  • J JasonL

    You can schedule a recurring daily cloud code script to run after the completion of your daily tournament. This script will use the GetGlobalLeaderboardPage method to retrieve the daily tournament winner's information and score, then post it to the monthly tournament using the PostTournamentScoreOnBehalfOf method.


  • Recurring scheduled tasks?
  • J JasonL

    No, after modifying the desired running time and adding your code, simply run this script without any further configuration.


  • Recurring scheduled tasks?
  • J JasonL

    Here is an example of scheduling a weekly cloud code execution,

    "use strict";
    
    function main() {
        var response = {}
    
        bridge.logDebugJson("Script Inputs", data)
    
        const scriptName = data.scriptName
        const interval = data.args.interval
        const searchSpan = interval < 60 ? 60 : 60 * 24
    
        // schedule checking and re-schedule itself for the next week at 23:59 on the same day
        var scriptProxy = bridge.getScriptServiceProxy()
    
        var dateTimeSpanMinsFromNowInMillis = new Date().getTime() + (searchSpan * 60 * 1000)
        var result = scriptProxy.getScheduledCloudScripts(dateTimeSpanMinsFromNowInMillis)
    
        var nowTime = new Date().getTime()
    
        if ((result.status == 200) && (result.data !== null)) {
            for (var i = 0; i < result.data.scheduledJobs.length; i++) {
                if (result.data.scheduledJobs[i].scriptName === scriptName && result.data.scheduledJobs[i].scheduledStartTime > nowTime) {
                    scriptProxy.cancelScheduledScript(result.data.scheduledJobs[i].jobId)
                }
            }
        }
    
        const targetHour = 23
        const targetMinute = 59
        const minutesDifference = getMinutesDifference(targetHour, targetMinute)
        let minutesFromNow = minutesDifference + interval
        bridge.logInfo(`minutesFromNow between the script calling time and the time of 23:59 on a same day${minutesFromNow}`)
        response.scheduleJob = scriptProxy.scheduleRunScriptMinutes(scriptName, data, minutesFromNow)
    
        // the code for your script 
    
        return response
    }
    
    function getMinutesDifference(targetHour, targetMinute) {
        const now = new Date()
        const targetTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), targetHour, targetMinute)
        const differenceInMilliseconds = targetTime - now
        bridge.logInfo(`differenceInMilliseconds between the script calling time and the target time: ${differenceInMilliseconds}`)
        const differenceInMinutes = Math.floor(differenceInMilliseconds / (1000 * 60))
        return differenceInMinutes
    }
    
    main()
    

    The parameters for this script will be like below, the interval will be 10080 minutes (a week),

    {
      "scriptName": "thisScriptNameItself",
      "args": {
        "interval": 10080
      }
    }
    

  • App Store Receipt Signing Intermediate Certificate
  • J JasonL

    Thank you for sharing this information. It does not have an impact on our server-side validation.


  • Webhook routes
  • J JasonL

    How about passing the slug as a parameter along with the webhook URL? This will allow your script to parse the parameter and perform actions accordingly.


  • Log timestamp to local time
  • J JasonL

    Are you referring to the date/time display format on the portal?


  • Follow up question for bulk user entity data access
  • J JasonL

    You can achieve it by writing a cloud code script that retrieves the data of each individual user's user entities and stores it in a custom entity collection. After that, call the method RunBatchUserScript() to execute this process for every user within the app. Then, the resulting collection can be downloaded for analytical purposes.


  • Localization Issue
  • J JasonL

    Thank you for letting us know. We have resolved the issue for your appId 14822.

  • Login

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