Step-by-step guide by Roy Smith, Founder & CEO of PrivacyCheq and newest addition to the SDKBOX family
If you are creating games for the U.S. Google or Apple app stores, you should be familiar with the Children’s Online Privacy Protection Act (COPPA). This U.S. privacy law details how content creators must deal with “Personally Identifiable Information” (PII) collected from children under the age of 13. If you’d like to learn more about the law, visit http://gamesauce.org/news/2014/11/19/what-developers-should-know-about-coppa/. There is a similar law coming for the European Union countries that is expected to go into effect in January 2016. When the DPD is in force, we expect that the AgeCheq service will provide you with compliance without even needing to recompile your game.
AgeCheq is the newest addition to the SDKBOX family, bringing simple COPPA compliance to the Cocos2d-x platform. AgeCheq takes the heavy lifting out of making a COPPA solution from scratch. Parents can prove their identity easily through the AgeCheq parental dashboard and only one API call needs to be integrated into your game to make it COPPA compliant.
Using the CLI to create Cocos2d-x project and add AgeCheq
To get started, open up your terminal window and go to the folder you’d like to create your new project. Create a new Cocos2d-x build with a CLI command.
$ cocos2d-x new MyGame –p com.mygame.new –l cpp
Note, this example will be written in C++. If you haven’t installed Cocos2d-console yet, here’s a tutorial to help get setup: http://www.cocos2d-x.org/wiki/Cocos2d-console
Now we move to the folder that was just created called “MyGame”. If you have an older version of Cocos2d-x where SDKBOX isn’t included, you can follow these steps to install it: http://sdkbox-doc.github.io/en/installer/. Now we use the SDKBOX CLI command to include AgeCheq into your project.
$ sdkbox import agecheq
This will add all the files needed for AgeCheq to work. iOS builds will now have all the needed files. The SDKBOX installer will also inject a sample Agecheq App ID and Dev Key into the res/sdkbox_config.json.
If you are building for Android, you can follow these instructions to update the necessary files: http://sdkbox-doc.github.io/en/plugins/agecheq/v3-cpp/#modify-cocos2dxactivityjava
Create Developer and Parent AgeCheq accounts
First, create your AgeCheq developer account. Go to http://www.developer.agecheq.com and click the sign-in/sign-up button located in the top right of the page. Fill in the needed credentials and sign up. When you’re logged into the dashboard, select the “Account” button in the top right. Here is where you can find your Developer API Key that is used to call the service.
For each game you wish to add AgeCheq to, select the “Add a New App” button in the top left. Enter the game’s name, then hit “Save”. The App ID will be on the next screen right below the application’s name.
Now that your ID and key has been created, copy them and replace the AgeCheq App ID and Dev Key in the res/sdkbox_config.json file with your newly generated ones.
To test your integration, it’s necessary to create a Parent AgeCheq account. Go to http://www.parent.agecheq.com. Select the sign-in/sign-up button and enter the needed credentials. Follow the directions and create a test child on the next screen. You will need to choose a PIN that the child will use to login. You will use this “AgeCheq PIN” later when you test your game.
Adding AgeCheq functions into an application
Now that SDKBOX is installed and you have setup your own Dev Key, App ID, and AgeCheq PIN, let’s integrate the AgeCheq calls and callbacks. In the “Hello World” header file, add the include path to the AgeCheq Plugin Header file.
Extend the HelloWorld class with sdkbox::AgeCheqListener. It should look something like this:
class HelloWorld : public cocos2d-x::Layer, sdkbox::AgeCheqListener
This class is now an AgeCheqListener and can be used to respond to callbacks. We can now add the two AgeCheq callback functions. Add this code under Public inside the HelloWorld class:
void checkResponse(const std::string& rtn,
const std::string& rtnmsg,
void associateDataResponse(const std::string& rtn,
const std::string& rtnmsg);
Moving onto HelloWorldScene.cpp, add this #include tag to the top:
We need to then initiate the plugin and set the listener to the HelloWorld class. To do this, we add calls to the top of HelloWorld::init . The AgeCheq setListener command will set the callback listener so we can see the results of our calls.
To know if we’ve been successful, let’s make the check response function log all the information we will get from the call back.
void HelloWorld::checkResponse(const std::string& rtn,
const std::string& rtnmsg,
CCLOG(“AgeCheq rtn:%s, rtnmsg:%s, apiversion:%d, checktype:%d, appauthorized:%u, appblocked:%u, parentverified:%d, under13:%u, under18:%u, underDevAge:%u, trials:%d”, rtn.c_str(), rtnmsg.c_str(), apiversion, checktype, appauthorized, appblocked, parentverified, under13, under18, underdevage, trials );
We also have to create a function in the HelloWorld CPP file to deal with the associate data command. We’ll just CCLOG out the return information as well. This command is only used when a developer would like to associate a generated unique identifier with the child account. In the COPPA law, the parent is allowed to revoke permission to an application or website. When the parent revokes that permission, the developer is required to delete all data collected on that child. Associating your unique identifier with the child account makes it easier for you to find the data needed deleted if that ever happens.
void HelloWorld::associateDataResponse(const std::string& rtn,
const std::string& rtnmsg)
CCLOG(“AgeCheq rtn:%s, rtnmsg:%s”, rtn.c_str(), rtnmsg.c_str());
Now we add two calls at the end of the HelloWorld::init to see if we can get the responses we want. Just use these statements with your
AgeCheq PIN that you generated earlier:
sdkbox::PluginAgeCheq::associateData(“<AgeCheq PIN>”, “test”);
Testing the Game
Compile the game, whether in Xcode or via the command line. After compiling, look at the CCLOG (bottom right in Xcode). There should be a response to the call with all variables being shown. You can then go to the parent AgeCheq account you setup earlier and see if the test app you created showed up under that AgeCheq PIN.
The AgeCheq API should now be fully working in your demo application. From here, a UI will need to be created that allows parents to enter their AgeCheq PIN and submit it. The check function should be called on submit to make sure that your app is authorized under that AgeCheq PIN. After you get back the response that the application is authorized, you can allow the user to play the game and you’re allowed to collect any information you disclosed to the parent. To update the list of information your app collects, go to the developer dashboard and under the application, select “What’s collected”.
If you have any questions about integrating AgeCheq or any steps in this tutorial, feel free to reach out to me at Tyler@privacycheq.com and I’d be glad to help.
If you’d like to watch video tutorial for a better understanding of AgeCheq and SDKBOX, you can view it here: https://vimeo.com/134869134.