The Google+ Platform

Vision

Help app developers create more engaging social experience and connect with more users

Opportunity

Mobile is the future

50%+

Google+ users are on mobile

Google+ Platform for Mobile

Android + iOS SDKs

Agenda

  • Platform overview

  • A complete mobile story

    • Meaningful identity: a more personalized experience

    • Lightweight social actions: bringing people together

    • Writing moments: saving and sharing memories

  • The HikePlanner app

  • Q&A

Google Play services

The hiking problem

Meaningful identity

a more personalized experience

Sign in with Google+

Identity ➤ Lightweight actions ➤ Moments

Sign in with Google+

Identity ➤ Lightweight actions ➤ Moments


Specify the permissions

<uses-permission android:name="android.permission.GET_ACCOUNTS"/>


and include a button

<com.google.android.gms.plus.PlusSignInButton
    android:id="@+id/sign_in_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
  

Sign in with Google+

Identity ➤ Lightweight actions ➤ Moments


Implement the interface

public class YourActivity extends Activity implements
       ConnectionCallbacks, OnConnectionFailedListener {
  private ProgressDialog mConnectionProgressDialog;
  private PlusClient mPlusClient;
  private ConnectionStatus mConnectionStatus;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPlusClient = new PlusClient(this, this, this, Scopes.PLUS_PROFILE);
    mConnectionProgressDialog = new ProgressDialog(this);
    mConnectionProgressDialog.setMessage("Signing in...");
  }
  .
  .
  .

Sign in with Google+

Identity ➤ Lightweight actions ➤ Moments


Implement the interface

    /*Override the lifecycle methods*/
    @Override protected void onStart() { ... }
    @Override protected void onStop() { ... }

    @Override public void onConnected() { ... }
    @Override public void onDisconnected() { ... }

    @Override public void onConnectionFailed(ConnectionStatus status) 
    {
      mConnectionStatus = status; 
    }

Sign in with Google+

Identity ➤ Lightweight actions ➤ Moments



Configure the button's listener

@Override
public void onClick(View view) {
  if (view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) {
    if (mConnectionStatus == null) {
      mConnectionProgressDialog.show();
    } else {
      mConnectionStatus.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
    }
  }
}

Sign in with Google+

Identity ➤ Lightweight actions ➤ Moments



Handle the result of signing in the user

@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == REQUEST_CODE_RESOLVE_ERR) {
    if (responseCode == RESULT_OK) {
      mConnectionStatus = null;
      mPlusClient.connect();
    }
  }
}

Meaningful identity

Demo

Lightweight social actions

bringing people together

Mobile +1 button

Identity ➤ Lightweight actions ➤ Moments

Mobile +1 button

Identity ➤ Lightweight actions ➤ Moments

Add the button to the layout

<com.google.android.gms.plus.PlusOneButton
    xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
    android:id="@+id/plus_one_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    plus:size="standard"/>

assign and set its URL in onCreate

PlusOneButton plusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
plusOneButton.initialize(mPlusClient,
  "http://hikeplannerapp.appspot.com/pointReyes.html");

Sharing into Google+

Sharing into Google+

Identity ➤ Lightweight actions ➤ Moments

Sharing into Google+

Identity ➤ Lightweight actions ➤ Moments



Send the intent with pre-populated text

Intent shareIntent = ShareCompat.IntentBuilder.from(YourActivity.this)
  .setText("Hey, I'm going on a hike in 15 minutes. Who wants to join?")
  .setType("text/plain")
  .getIntent()
  .setPackage("com.google.android.apps.plus");

startActivity(shareIntent);

Sharing into Google+

Identity ➤ Lightweight actions ➤ Moments

or a URL

Intent shareIntent = ShareCompat.IntentBuilder.from(YourActivity.this)
  .setText("I'm going on a hike in 15 minutes. Who wants to join?
    Thinking of hitting up this trail:
    http://hikeplannerapp.appspot.com/pointReyes.html")
  .setType("text/plain")
  .getIntent()
  .setPackage("com.google.android.apps.plus");

startActivity(shareIntent);

Sharing into Google+

Identity ➤ Lightweight actions ➤ Moments


Even attach media to your post with setStream

Intent shareIntent = ShareCompat.IntentBuilder.from(YourActivity.this)
  .setText("Time to go on a hike! Don't you want to experience nature 
    and not just your desk?")
  .setStream(DATA_URI)
  .setType(MEDIA_TYPE)
  .getIntent()
  .setPackage("com.google.android.apps.plus");

startActivity(shareIntent);

and optionally target your intent directly to Google+ with setPackage

Lightweight social actions

Demo

Write moments to Google+ history

saving and sharing memories


Write moments to Google+ history

Identity ➤ Lightweight actions ➤ Moments


Write moments to Google+ history

Identity ➤ Lightweight actions ➤ Moments

Constructing and sending the Moment intent


JSONObject place = new JSONObject();
place.put("url", "http://hikeplannerapp.appspot.com/pointReyes.html");

JSONObject moment = new JSONObject();
moment.put("type", "http://schemas.google.com/CheckInActivity");
moment.put("target", place);

Intent intent = new Intent("com.google.android.gms.plus.activity.WRITE_MOMENT");
intent.putExtra("com.google.android.gms.EXTRA_MOMENT_JSON", moment.toString());
startActivityForResult(intent, REQUEST_CODE_WRITE_MOMENT);

The HikePlanner App

Demo

A teaser

Signing in with Google+ on iOS

Add and configure the button

signInButton.delegate = self;
signInButton.clientId = @"YOUR_CLIENT_ID";
signInButton.scope = 
  [NSArray arrayWithObject:@"https://www.googleapis.com/auth/plus.me"];

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

appDelegate.signInButton = signInButton;

Implement the GooglePlusSignInDelegate delegate

- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
                   error: (NSError *) error;

Signing in with Google+ on iOS

Forward declare the class and the sign in button in your app delegate

@class GooglePlusSignInButton;

@property (retain, nonatomic) GooglePlusSignInButton *signInButton;

Handle URLs in your application's delegate

- (BOOL)application: (UIApplication *)application
            openURL: (NSURL *)url
  sourceApplication: (NSString *)sourceApplication
         annotation: (id)annotation {
  if ([signInButton_ handleURL:url
             sourceApplication:sourceApplication
                    annotation:annotation]){ return YES; }

Sharing to Google+ on iOS

Create the share object

GooglePlusShare *share = [[GooglePlusShare alloc] initWithClientID:clientID];

share.delegate = self;

Populate and open the sharebox

NSURL *shareURL = 
  [NSURL urlWithString:@"http://hikeplannerapp.appspot.com/pointReyes.html"];

[[[[share shareDialog] 
  setURLToShare:shareURL]
  setPrefillText:@"Let's go on a hike together!"] open];

Write moments on iOS

Construct and send a moment

GTLServicePlus *plusService = [[GTLServicePlus alloc] init];
GTLPlusMoment *moment       = [[GTLPlusMoment alloc] init];
GTLPlusItemScope *place     = [[GTLPlusItemScope alloc] init];

place.url = 
  [NSURL urlWithString:@"http://hikeplannerapp.appspot.com/pointReyes.html"];
moment.type = [NSMutableString @"http://schema.google.com/CheckInActivity"];
moment.target = place;

GTLQueryPlus *query =
  [GTLQueryPlus queryForFramesInsertWithObject:moment 
                                          userId:@"me"
                                      collection:kGTLPlusCollectionVault];

[plusService execuGteQuery:query completionHandler:...];

Resources

Thank You!