CloudBuilder  2.8.4
Making social games is easy !
Google+ Settings

Table of Content

  1. Google+ Developer
  2. Google+ on iOS
  3. Google+ on Android

Setup a Google+ App

To be able to log in CloudBuilder with the user's Google+ account, you need to create a Google+ App

Here, you need to create a new project from the Developers Console. Just push the "Create" button, then choose a name for your project, and you're good to go.

Create a new Project in Developers Console

Once the project is created, it will appear in the list of your managed projects and you can click on it. This will display the overview of the project, giving you the Project Number you will have to reference in your different applications.

Your Google+ Project Number

From the overview, you now need to activate the Google+ API. From the left menu of the overview, press "APIs & auth" and in the sub section "APIs", make sure to activate the "Google+ API". Your application is now authorized to use Google+ single sign on.

Activating Google+ API for your Project

When done, you now just need to create new Client IDs for iOS and Android, using the OAuth section. You can access it from the "APIs & auth" left menu, "Credentials" sub section.

Creating OAuth Client IDs

Google+ on iOS

To finish creating an iOS Client ID, in the popping window, choose "Installed application" as APPLICATION TYPE and below INSTALLED APPLICATION TYPE, choose iOS option. Then fill the BUNDLE ID field with the same bundle id used in your iOS application, in the plist file (Bundle identifier entry).

Creating iOS Client ID

When this is done, look at the Client ID generated for you, and keep it, you will need it now to edit your Xcode project (see below)

Getting iOS Client ID

Then in Xcode, go to the "Info" section of your project and first create a "GooglePlusAppID" key entry. In the value field, you will copy/paste the Client ID from the previous screen, as generated by Google. Then, you need to create a new "URL Type" entry, just filling "Identifier" and "URL Schemes" fields with your Bundle Identifier. Leave the other fields empty.

Modifying Xcode project

It's almost finished. Just check that you have all the necessary frameworks linked to your project by checking the "Build Phases" tab of your project.

Checking mandatory frameworks

Lastly, just ensure that you have the following code in the AppDelegate of your project:

1 - (BOOL)application:(UIApplication *)application
2  openURL:(NSURL *)url
3  sourceApplication:(NSString *)sourceApplication
4  annotation:(id)annotation {
5  // attempt to extract a token from the url
6  if (CClan::Instance() && url)
7  {
9  CHJSON j;
10  j.Put("url", [[url absoluteString ] UTF8String]);
11  j.Put("source", [sourceApplication UTF8String]);
12  CClan::Instance()->HandleURL(j, new CloudBuilder::CResultHandler(myClan, &MyClan::HandleURLDone));
13  }
15  return false;
16 }

Google+ on Android

You need to get your SHA1 signing certificate fingerprint in order to create a new Android Google+ application. To do so, you have different options. First option is to type into a terminal the following command:

1 keytool -exportcert -alias androiddebugkey -keystore {path-to-debug-or-production-keystore} -list -v

When debugging you can use '~/.android/debug.keystore' as the path. Then copy the string displayed after the line beginning with 'SHA1: '. Alternatively, you can use Eclipse to get this SHA1 string. In the menu ADT/Preferences, go to the Android/Build panel and copy the string directly from here.

Getting SHA1 signing certificate

To finish creating an Android Client ID, in the popping window, choose "Installed application" as APPLICATION TYPE and below INSTALLED APPLICATION TYPE, choose Android option. Then fill the PACKAGE NAME field with the one used to build your APK, and the SIGNING CERTIFICATE with the string retrieved from the previous step.

Creating Android Client ID

Then you need to import the Android project {Repository/CloudBuilder/Android/google-play-services-lib} in your Eclipse workspace. When this is done, edit the "Properties/Android" panel of your application inside Eclipse, and add a new Library referencing the GooglePlay Services Library.

Referencing GooglePlay Services Library

To finish the setup of Google+ in your Android application, you need to add some code and modify the ApplicationManifest.xml Add the following code in the onCreate method of your Activity:

1 protected void onCreate(Bundle savedInstanceState) {
2  super.onCreate(savedInstanceState);
5  // All your instanciation code is here.
7  // This code to enable Google+ login in Clan of the Cloud
8  GooglePlusHandler.InitGooglePlayServices(this, null);
10 }

Add the following code in the onActivityResult method of your Activity:

1 public void onActivityResult(int requestCode, int resultCode, Intent data) {
2  super.onActivityResult(requestCode, resultCode, data);
4  // All your previous code is here.
6  // This code to enable Google+ login in Clan of the Cloud
7  GooglePlusHandler.onResultGooglePlusActivity(requestCode, resultCode);
8 }

Add the following entry in the AndroidManifest.xml inside the <application> tag:

1 <meta-data android:name="" android:value="@integer/google_play_services_version"/>