# Base

**URL:** https://heroiclabs.com/docs/hiro/concepts/base/
**Summary:** A group of features that are common to all games.
**Keywords:** in-app purchases, IAP validation, receipt validation, push notifications, app rating, default usernames, crash reporting, Firebase Crashlytics, player initialization
**Categories:** hiro, base, concepts

---


# Base

The `Base` module of Hiro is not a game system like the other features, but rather an aggregated group of smaller features that are common to  most, if not all, games. It includes the following features and functionality:

## In-app purchases

Hiro connects your platform stores to the economy system through Nakama's server-side receipt validation. Store items configured with a [`sku`](/docs/hiro/concepts/economy/virtual-store/#virtual-store-configuration) in your economy config are registered with the platform store automatically on initialization. When a player completes a purchase, the client submits the receipt to Nakama, which validates it with Apple App Store or Google Play before granting the reward defined in your economy config.

The full IAP flow is handled without custom server logic: product registration, platform purchase, receipt validation, and reward delivery. Your economy configuration is the single source of truth for what products exist and what rewards they grant.

See [In-app purchase validation](/docs/nakama/concepts/iap-validation/) for Nakama server configuration, and your client SDK reference for implementation details. For Unity, see [How to implement IAPs in Unity](/docs/hiro/guides/unity/unity-iap/).

## App rating

{{< screenshot
  src="/images/pages/hiro/concepts/rating.png"
  alt="In-app rating popup dialog in Merge Chef 3D asking the player to rate the game with star icons"
  caption="An app rating popup in Merge Chef 3D by Kyoso Interactive."
  border-style="none"
>}}

The user ratings a name receives can significantly impact its visibility and success. Positive ratings and reviews can help attract new users and improve your app's ranking in app stores, which in turn can increase downloads and revenue. 

Along with the focus on providing a high-quality gaming experience, you should be actively soliciting feedback from your most active and engaged users to ensure you receive positive ratings and reviews.

You can use the `InAppReviewSystem` to trigger a native app store review.

### Customization parameters

The following JSON represents the customization parameters you can use to configure the `Base` module.

```json
{
    "rate_app_smtp_addr": "smtp.gmail.com",
    "rate_app_smtp_username": "email@domain.com",
    "rate_app_smtp_password": "password",
    "rate_app_smtp_email_from": "gamename-server@mygamecompany.com",
    "rate_app_smtp_email_from_name": "My Game Company",
    "rate_app_smtp_email_subject": "RateApp Feedback",
    "rate_app_smtp_email_to": "gamename-rateapp@mygamecompany.com",
    "rate_app_smtp_port": 12345,
    "rate_app_template": "<template>"
}
```

You may define the following:

{{< table name="gdk.concepts.base.base-system" >}}

## Push notifications

Push notifications can be used to improve your mobile game in several ways, including:

* **Player engagement**: Notify players of new content or events, encouraging them to return to the game and increasing engagement.
* **Retention**: By reminding players to come back to the game after a certain amount of time has passed, push notifications can help improve player retention.
* **Monetization**: Promote in-game purchases or special offers, encouraging players to spend money within the game.
* **Social interactions**: Encourage players to interact with friends or join multiplayer sessions.

In practice, you should keep in mind the timing and frequency of notifications sent, ensuring they are relevant and add value to the player's experience without being intrusive.

## Default usernames

In addition to the ability to set player usernames in the [usual manner with Nakama](../../../nakama/concepts/authentication/), Hiro provides for the creation of default usernames for players when they first log in. 

These usernames follow a default format, for example `Player000000001` (prefix + nine digits), which is a common representation seen in many games.

## Profanity filtering

Many areas of Hiro let players submit custom strings for names, descriptions, and chat messages.

You can enable profanity filtering for the relevant Hiro systems listed below. Set a threshold between 0.0 and 1.0 to control strictness.
Each string is scored from 0.0 to 1.0, where higher scores mean the filter is more confident that the string contains profanity.
A threshold of 1.0 rejects only explicitly defined examples, whereas 0.9 also rejects strings that are very similar but not an exact match.

{{< code hideable="false" >}}
```go
systems, err := hiro.Init(ctx, logger, db, nk, initializer, binPath, hiroLicense,
  hiro.WithBaseSystem(fmt.Sprintf("definitions/%s/base-system.json", env), true,
    hiro.WithBaseSystemProfanityFilterChat(0.9),
    hiro.WithBaseSystemProfanityFilterUsername(0.9),
    hiro.WithBaseSystemProfanityFilterDisplayName(0.9),
    hiro.WithBaseSystemProfanityFilterTeamName(0.9),
    hiro.WithBaseSystemProfanityFilterTeamDescription(0.9),
    hiro.WithBaseSystemProfanityFilterChallengeName(0.9),
    hiro.WithBaseSystemProfanityFilterChallengeDescription(0.9),
  ),
  // other system initialization
)
if err != nil {
  return err
}
```
{{< / code >}}

### Filter override

By default, Hiro uses [go-away](https://github.com/TwiN/go-away). If you wish to use your own third-party filtering library or service instead, make the following adjustments:

{{< code hideable="false" >}}
```go
systems, err := hiro.Init(ctx, logger, db, nk, initializer, binPath, hiroLicense,
  hiro.WithBaseSystem(fmt.Sprintf("definitions/%s/base-system.json", env), true,
    // other profanity configuration methods
    hiro.WithBaseSystemProfanityFilter(CustomFilterFn),
  ),
  // other system initialization
)
if err != nil {
  return err
}

func CustomFilterFn(content string) (float64, string, error) {
  // pass "content" into your filtering library/service
  // return how likely it is that "content" contains profanity, along with the censored version of "content"
  return confidenceOfProfanity, censoredContent, nil
}
```
{{< / code >}}

## Crash reporting

Built-in integration with [Firebase Crashlytics](https://firebase.google.com/docs/crashlytics) is provided to capture and forward all client-side crash logs. See the [Firebase](/docs/hiro/unity/analytics/#firebase) section of the Analytics page.
