Game Addiction Prevention and Trial Mode on Huawei(HMS)

YusufAltun
Huawei Developers
Published in
5 min readMar 5, 2021

Hi everyone,

In this article, I will talk about how to use Game Addiction Prevention(GAP) feature of HMS game services.

Before using GAP service you should configure your application for HMS Game services. Find more details about HMS game services in this:

Introduction

Video Game Addiction is nothing new and is doubtful to ever fade, it is mostly a term that is used by the media to describe those who play video games for excessive amounts of time. However in reality the average youth spends 50 hours a week in front of one screen or another a 2010 survey by the Kaiser Family Foundation reports. If two days out of seven is not addiction and is the average time spent then why do those who play games for such amount of time get classed as addicted?

An example of this is the BBC News article about a Chinese gamer who died after a three day gaming session.

HUAWEI Game Service is a service that help developers to create efficient games. With game services, you can enable user to sign in to your games and you can use user information to provide game addiction. But this feature is limited, and for now its just work in China mainland.

Huawei provides a game addiction prevention solution in accordance with the Notice on Preventing Addiction Among Minors in Online Games issued by the State Administration of Press and Publication. Developers shall develop the game addiction prevention function according to the notice and app implementation logic.

Precautions

  • Before implementing the game addiction prevention function, you need to contact Huawei operations personnel to enable the forcible identity verification function( Chinese mainland must support the identity verification function).
  • If the PlayersClient.submitPlayerEvent or PlayersClient.getPlayerExtraInfo API returns result code 7002 or 7006, process as follows:
  • 7002: Check whether the network is normal. If so, the account has not been registered in the Chinese mainland. In this case, perform bypass and no further action is required.
  • 7003: The API is called too frequently. In this case, change the API call interval to 15 minutes. (Delete apps cache also)
  • 7006: The account has not been registered in the Chinese mainland. In this case, perform bypass and no further action is required.

For china mainland account you can create new account on Appgallery:

  • Select base country as a China.
  • On security section you can give any country phone number for Huawei verification code.

After that in your phone you can login to AppGallery with this account.

China mainland test account

Preparations

When a player signs in to your game or switches your game from the background to the foreground, the game needs to report a game entering event. When a player exits your game or switches the game from the foreground to the background, the game needs to report a player exit event. HUAWEI Game Service calculates the played time of a player based on reported events. Games can query whether a player is an adult and the daily accumulated played time of the player from HUAWEI Game Service as references for performing game addiction prevention.

  • The played time of ongoing games refers to the time since the last game entering event in the current game (without any exit event reported later) plus the online durations in other games (time between game entering and the last online status confirmation plus 15 minutes).
  • The played time of exited games refers to the played time calculated based on game entering and exit events.
  • When a player successfully signs in, call the Games.getPlayersClient method to initialize the PlayersClient instance.
initilize parameters
  • When a player signs in to the game or switches the game from the background to the foreground, call the PlayersClient.getPlayerExtraInfo method to query the additional information about the player. After the result is obtained, call the PlayerExtraInfo.getIsAdult method to check whether the player is an adult.

If the player is underage, call PlayersClient.submitPlayerEvent(String eventId, String eventType) to report the event that the player enters the game. The game server sends back the transactionId of the player after receiving the event.

The game periodically calls the PlayersClient.getPlayerExtraInfo method to query the additional information about the player and passes the transaction ID returned after the event is reported. The minimum interval for querying player additional information is 10 minutes. It is recommended that the interval be set to 15 minutes.

If the player is a minor, call PlayerExtraInfo.getPlayerDuration to view the accumulated played time of the player, which is the up-to-date accumulated played time of the player on the current day. Your game needs to perform game addiction prevention on minor players based on the accumulated played time. You need to implement the prevention logic for your game.

When a player exits your game or switches your game from the foreground to the background, or the game exits unexpectedly (for example, the process terminates or the mobile phone restarts), call PlayersClient.submitPlayerEvent(String eventId, String eventType) again to report a player exit event.

Trial Mode

According to relevant rules published by China’s State Administration of Press and Publication, an online game can provide a trial of up to one hour for guest players. In the guest mode, a player does not need to perform identity verification, but cannot top up their account or make payments. A device can have another trial at least 15 days after the last trial.

Huawei game server also provides the guest mode to allow games that support the trial mode to display trial play option in the identity verification pop-up for a player. After the trial ends, Huawei game server will send a notification to inform you of the identity verification result. Then you can execute processing accordingly.

For trial mode we are using PlayersClient class. After initilize this class we can call setGameTrialProcess function, this funtion listens to trial duration expiration. For handling exception we need to implement GameTrialProcess functions.

Thank you for reading this article.

I hope this gives you a starting point for Huawei Mobile Services and Unity integration.

Reference

--

--