GPGManager Class Reference

GPGManager Class Reference

Overview

The starting point for interacting with Google Play Games.

GPGManager is accessed as a singleton through the sharedInstance method. Any attempts to allocate a manager object explicitly will fail.

There are two ways to sign in to Google and start using Google Play Games. You may choose to use the simplified flow and ask GPGManager to handle the entire sign-in flow for you, or take full control of the Google+ Sign-In SDK yourself and hand over the sign-in result to GPGManager in the end.

Use signInWithClientID:silently: or signInWithClientID:silently:withExtraScopes: for the simplified flow. Use signIn for the advanced flow. See the Sign-in section of the Developer's Guide for details.

Public Member Functions

Authentication
(BOOL) - hasAuthorizer
 Deprecated.
(void) - signOut
 Ends the current authenticated session, if there is one.
(void) - signIn:reauthorizeHandler:
 Deprecated.
(void) - signIn
 Authenticate for Google Play Games.
(BOOL) - signInWithClientID:silently:
 Signs in to Google and Play Games in one step automatically.
(BOOL) - signInWithClientID:silently:withExtraScopes:
 Signs in to Google and Play Games in one step automatically.
Push Notifications
(BOOL) - tryHandleRemoteNotification:
 Attempts to handle a Play Games Services push notification payload.
(BOOL) - tryHandleRemoteNotification:forActionWithIdentifier:completionHandler:
 Attempts to handle a Play Games Services push notification payload.
(void) - registerDeviceToken:forEnvironment:
 Registers the device with Play Games Services for future push tokens.
(void) - unregisterCurrentDeviceToken
 Unregisters the device for future push notifications.

Static Public Member Functions

Singleton Access
(instancetype) + sharedInstance
 The singleton accessor method.

Properties

Properties
id< GPGTurnBasedMatchDelegateturnBasedMatchDelegate
 The delegate that will receive future match updates.
id< GPGRealTimeRoomDelegaterealTimeRoomDelegate
 The delegate that will receive future room updates.
id< GPGStatusDelegatestatusDelegate
 The delegate that will receive future GPG status updates.
id< GPGQuestDelegatequestDelegate
 The delegate that will receive future quest updates.
BOOL signedIn
 YES if the client has successfully signed in to Google Play Games.
BOOL appStateEnabled
 Whether AppState support is enabled.
BOOL snapshotsEnabled
 Whether Saved Game support is enabled.
NSUInteger sdkTag
Device Orientation
NSUInteger validOrientationFlags
 Deprecated.
NSUInteger welcomeBackOffset
 The offset from the specified edge of the screen to offset the Welcome Back popup.
GPGToastPlacement welcomeBackToastPlacement
 The desired display style for Welcome Back popups.
NSUInteger achievementUnlockedOffset
 The offset from the specified edge of the screen to offset the Achievement Unlocked popup.
GPGToastPlacement achievementUnlockedToastPlacement
 The desired display style for Achievement popups.
NSUInteger questCompletedOffset
 The offset from the specified edge of the screen to offset the Quest Complete popup.
GPGToastPlacement questCompletedToastPlacement
 The desired display style for Quest popups.

Application State

GPGApplicationModelapplicationModel
 Deprecated.
(NSString *) - applicationId
 Deprecated.

SDK Revision Check

GPGRevisionStatus revisionStatus
 Gets the current SDK deprecation status.
BOOL revisionValid
 Checks the SDK revision status from locally stored results without calling the server.
(void) - refreshRevisionStatus:
 Calls the Play Games server API to check for the latest SDK revision status.

Member Function Documentation

+ (instancetype) sharedInstance

The singleton accessor method.

Returns:
The single shared instance of the GPGManager object. If the singleton object does not already exist then it will be created.
- (NSString *) applicationId

Deprecated.

applicationId is now derived from the provided clientID.

- (BOOL) hasAuthorizer

Deprecated.

Use -[GPGManager isSignedIn] to check the Games service sign-in status. Or use -[GPPSignIn authentication] to get the autorizer object.

Returns the state of an existing authorizer object which holds the OAuth token.

Returns:
YES if the user has successfully authenticated themselves with Google. In this case there is an existing authorizer object which contains an OAuth token to be used to authorize requests. NO if there isn't an existing authorizer object available.
- (void) signOut

Ends the current authenticated session, if there is one.

This will release all of the models from memory, resetting the local Google Play Games state back to a non-authenticated state. This is completed asynchronously. Listen for completion with signInDelegate didFinishGamesSignOutWithError:(NSError *)error.

- (void) signIn: (GPPSignIn *)  signIn
reauthorizeHandler: (GPGReAuthenticationBlock)  reauthenticationBlock 

Deprecated.

Use signIn, signInWithClientID:silently: or signInWithClientID:silently:withExtraScopes:instead.

- (void) signIn

Authenticate for Google Play Games.

With this method, you can customize Google Sign-In yourself and need to go through Google Sign-In in your own code. You must have already signed in to Google before calling this method to sign in to Google Play Games.

Note: Use the "https:///www.googleapis.com/auth/games" scope for Google Sign-In.

Instructions: Google+ Sign-In for iOS

- (BOOL) signInWithClientID: (NSString *)  clientID
silently: (BOOL)  silently 

Signs in to Google and Play Games in one step automatically.

Using this method, you don't need to deal with GPPSignIn separately. This is the only method you need to call to finish both Google+ authentication and Play Games sign-in.

Parameters:
clientIDThe client ID for your game.
silentlyWhether to try silent Google sign-in. If set to YES, it will call [GPPSignIn trySilentAuthentication]. Otherwise, [GPPSignIn authenticate] will be called.
Returns:
The result from [GPPSignIn trySilentAuthentication] if silently is YES. Otherwise always returns NO.
- (BOOL) signInWithClientID: (NSString *)  clientID
silently: (BOOL)  silently
withExtraScopes: (NSArray *)  scopes 

Signs in to Google and Play Games in one step automatically.

It behaves the same as signInWithClientID:silently:, except that this allows setting extra custom scopes for the Google authentication process.

Parameters:
clientIDThe client ID for your game.
silentlyWhether to try silent Google sign-in. If set to YES, it will call [GPPSignIn trySilentAuthentication]. Otherwise, [GPPSignIn authenticate] will be called.
scopesAdditional scopes to use for Google authentication. The scopes included in the parameter should be other than the default scopes including "games" and "appstate".
Returns:
The result from [GPPSignIn trySilentAuthentication] if silently is YES. Otherwise always returns NO.
- (BOOL) tryHandleRemoteNotification: (NSDictionary *)  userInfo

Attempts to handle a Play Games Services push notification payload.

Returns YES if the payload is from Play Games Services and handles the payload automatically. The resulting room or match invites/updates are sent back through their respecitve delegates.

Parameters:
userInfothe raw push notification payload from either application:didFinishLaunchingWithOptions: or application:didReceiveRemoteNotification:
- (BOOL) tryHandleRemoteNotification: (NSDictionary *)  userInfo
forActionWithIdentifier: (NSString *)  identifier
completionHandler: (void (^)  completionHandler 

Attempts to handle a Play Games Services push notification payload.

Returns YES if the payload is from Play Games Services and handles the payload automatically. The resulting room or match invites/updates are sent back through their respecitve delegates. Introduced with iOS 8 to accomodate for push notification actions.

Parameters:
userInfothe raw push notification payload from either application:didFinishLaunchingWithOptions: or application:didReceiveRemoteNotification:
identiferthe identifier string of the push notification action (introduced in iOS 8) tapped upon receiving the invitation.
completionHandlerthe callback for the push notification action. This must be passed in instead of being called directly.
- (void) registerDeviceToken: (NSData *)  deviceTokenData
forEnvironment: (GPGPushNotificationEnvironment)  environment 

Registers the device with Play Games Services for future push tokens.

Call this after the user has signed in.

Parameters:
deviceTokenDatathe raw 32 byte device token given by Apple in application:didRegisterForRemoteNotificationsWithDeviceToken:
environmentthe APNS server to target. Use GPGPushNotificationEnvironmentSandbox for testing and GPGPushNotificationEnvironmentProduction for a deployed production environment.

Unregisters the device for future push notifications.

Automatically called at user sign out.

- (void) refreshRevisionStatus: (GPGRevisionCheckBlock)  revisionCheckHandler

Calls the Play Games server API to check for the latest SDK revision status.

Parameters:
revisionCheckHandlerA block that will be called when the server call returns the results. If current user isn't Google+ enabled, this block will not be called and the supplied reauthenticationBlock will be called instead.

Property Documentation

- (GPGApplicationModel *) applicationModel [read, assign]

Deprecated.

Creates and returns the model for this application. Notice: All models have been removed with the exception of appState.

Returns:
The GPGApplicationModel for this application.
- (id<GPGTurnBasedMatchDelegate>) turnBasedMatchDelegate [read, write, assign]

The delegate that will receive future match updates.

Assign this as early as possible.

- (id<GPGRealTimeRoomDelegate>) realTimeRoomDelegate [read, write, assign]

The delegate that will receive future room updates.

Assign this as early as possible.

- (id<GPGStatusDelegate>) statusDelegate [read, write, assign]

The delegate that will receive future GPG status updates.

Assign this as early as possible.

- (id<GPGQuestDelegate>) questDelegate [read, write, assign]

The delegate that will receive future quest updates.

Assign this as early as possible.

- (BOOL) signedIn [read, assign]

YES if the client has successfully signed in to Google Play Games.

- (BOOL) appStateEnabled [read, write, assign]

Whether AppState support is enabled.

Set this before signing in to request the corresponding scope for AppState. Changing this after sign-in won't have any effect.

- (BOOL) snapshotsEnabled [read, write, assign]

Whether Saved Game support is enabled.

Set this before signing in to request the corresponding scope for Saved Games. Changing this after sign-in won't have any effect.

- (NSUInteger) validOrientationFlags [read, write, assign]

Deprecated.

This may be removed from a future release. You can set the possible device orientations for achievement unlocked popups by performing a bitwise inclusive OR against the value of (1 << UIDeviceOrientation).

NSUInteger flags = 0;
flags <code>= (1 << UIDeviceOrientationPortrait)
flags <code>= (1 << UIDeviceOrientationPortraitUpsideDown)
[GPGManager sharedInstance].validOrientationFlags = flags;

NSUInteger flags = 0;
flags <code>= (1 << UIDeviceOrientationLandscapeLeft)
flags <code>= (1 << UIDeviceOrientationLandscapeRight)
[GPGManager sharedInstance].validOrientationFlags = flags;

NSUInteger flags = 0;
flags <code>= (1 << UIDeviceOrientationPortrait)
flags <code>= (1 << UIDeviceOrientationPortraitUpsideDown)
flags <code>= (1 << UIDeviceOrientationLandscapeLeft)
flags <code>= (1 << UIDeviceOrientationLandscapeRight)
[GPGManager sharedInstance].validOrientationFlags = flags;
- (NSUInteger) welcomeBackOffset [read, write, assign]

The offset from the specified edge of the screen to offset the Welcome Back popup.

If the welcomeBackToastPlacement is set to kGPGToastPlacementTop, then this offset is from the top. If the welcomeBackToastPlacement is set to kGPGToastPlacementBottom, then this offset is from the bottom. If the welcomeBackToastPlacement is set to kGPGToastPlacementCenter, then this offset is ignored.

- (GPGToastPlacement) welcomeBackToastPlacement [read, write, assign]

The desired display style for Welcome Back popups.

- (NSUInteger) achievementUnlockedOffset [read, write, assign]

The offset from the specified edge of the screen to offset the Achievement Unlocked popup.

If the achievementUnlockedToastPlacement is set to kGPGToastPlacementTop, then this offset is from the top. If the achievementUnlockedToastPlacement is set to kGPGToastPlacementBottom, then this offset is from the bottom. If the achievementUnlockedToastPlacement is set to kGPGToastPlacementCenter, then this offset is ignored.

- (GPGToastPlacement) achievementUnlockedToastPlacement [read, write, assign]

The desired display style for Achievement popups.

- (NSUInteger) questCompletedOffset [read, write, assign]

The offset from the specified edge of the screen to offset the Quest Complete popup.

If the questCompletedToastPlacement is set to kGPGToastPlacementTop, then this offset is from the top. If the questCompletedToastPlacement is set to kGPGToastPlacementBottom, then this offset is from the bottom. If the questCompletedToastPlacement is set to kGPGToastPlacementCenter, then this offset is ignored.

- (GPGToastPlacement) questCompletedToastPlacement [read, write, assign]

The desired display style for Quest popups.

- (GPGRevisionStatus) revisionStatus [read, assign]

Gets the current SDK deprecation status.

Returns:
GPGRevisionStatusOK if the current SDK is up-to-date. GPGRevisionStatusDeprecated if the current SDK is deprecated but still working. You are strongly encouraged to upgrade the SDK. GPGRevisionStatusInvalid if the current SDK is no longer supported. All server calls from the SDK to the Games service will stop working at this point. GPGRevisionStatusUnknown if the SDK cannot retrieve the status from the Games service yet.
- (BOOL) revisionValid [read, assign]

Checks the SDK revision status from locally stored results without calling the server.

Returns:
YES if the current SDK is up-to-date or is deprecated but still working. NO if the current SDK is already out of support. All server calls from the SDK to the Games service will stop working at this point.

Оставить отзыв о...

Текущей странице
Play Games Services for iOS
Play Games Services for iOS