Base #

Read more about the Base system in Hiro here.

Functions #

RateApp #

Use the SMTP configuration to send feedback from a player via email.

1
2
3
4
5
6
7
8
9
userId := "userId"
username := "username"
var score uint32 = 5
message := "I love this game!"

err := systems.GetBaseSystem().RateApp(ctx, logger, nk, userId, username, score, message)
if err != nil {
  return err
}

SetDevicePrefs #

Set push notification tokens on a user’s account so push messages can be received.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
userId := "userId"
deviceId := "deviceId"
pushTokenAndroid := "pushTokenAndroid"
pushTokenIos := "pushTokenIOS"
preferences := map[string]bool{} // Used to store device specific parameters.

err := systems.GetBaseSystem().SetDevicePrefs(ctx, logger, db, userId, deviceId, pushTokenAndroid, pushTokenIos, preferences)
if err != nil {
  return err
}

Sync #

Manually trigger a sync operation to update the server with offline state changes.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
userId := "userId"
req := &hiro.SyncRequest{
  Inventory:         nil,
  Economy:           nil,
  Achievements:      nil,
  Energy:            nil,
  EventLeaderboards: nil,
  Progressions:      nil,
  Stats:             nil,
  Tutorials:         nil,
  Unlockables:       nil,
  Streaks:           nil,
} // Manually update system offline state.

resp, err := systems.GetBaseSystem().Sync(ctx, logger, nk, userId, req)
if err != nil {
  return err
}