2014. 1. 20. 19:06
# 추가해야하는 FrameWorks
> 다운받아서 추가해야 하는 frameWorks
GoogleOpenSource.framework, GooglePlus.bundle, GooglePlus.framework

> 자체라이브러리에서 추가해야 하는 frameworks
CoreMotion.framework, MobileCoreServices.framework, CoreText.framework, AssetsLibrary.framework

Build Setting 의 other linker flag 에 -ObjC 옵션 추가할것 (빠지면 Link Error 발생함)



AppDelegate.h


#import <GooglePlus/GooglePlus.h>


@interface AppDelegate : UIResponder <UIApplicationDelegateGPPDeepLinkDelegate>


- (void)didReceiveDeepLink:(GPPDeepLink *)deepLink;


AppDelegate.m


#import <GooglePlus/GooglePlus.h>

...

static NSString * const GooglePlusAppClientID = @"App Key";


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

[GPPSignIn sharedInstance].clientID = GooglePlusAppClientID;

...

[GPPDeepLink setDelegate:self];

[GPPDeepLink readDeepLinkAfterInstall];

}


ViewController.h


#import <GooglePlus/GooglePlus.h>


- (IBAction)OnTouchUpGooglePlusLogin:(id)sender;



ViewController.m


#import <GoogleOpenSource/GoogleOpenSource.h>

#import <GooglePlus/GooglePlus.h>


/* For GooglePlusLogin

 by YG.Seo 2014.1.16 */

- (IBAction)OnTouchUpGooglePlusLogin:(id)sender

{

    GPPSignIn *signIn = [GPPSignIn sharedInstance];

    signIn.shouldFetchGooglePlusUser = YES;

    signIn.shouldFetchGoogleUserEmail = YES;

    signIn.delegate = self;

    

    if([signIn authentication] == nil)

    {

        [signIn authenticate];

    }

    else

    {

        [signIn disconnect];

    }

}


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

    if (error) {

        NSLog(@"Received error %@ and auth object %@",error, auth);

        return;

    }

    m_strGooglePlusAccount = [GPPSignIn sharedInstance].userEmail;

    NSLog(@"GooglePlusUser : %@", m_strGooglePlusAccount);


}

- (void)didDisconnectWithError:(NSError *)error {

    if (error) {

        NSLog(@"Status:Failed to disconnect: %@", error);

    } else {

        NSLog(@"Status: Disconnected");

    }

}

Posted by 은돌군