Build Setting 의 other linker flag 에 -ObjC 옵션 추가할것 (빠지면 Link Error 발생함)
AppDelegate.h
#import <GooglePlus/GooglePlus.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, GPPDeepLinkDelegate>
- (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");
}
}
'Computer Programming > Object C' 카테고리의 다른 글
[ObjectC/Iphone]IOS 어플리케이션과 viewController의 생명 주기 (0) | 2014.01.22 |
---|---|
[ObejctC/Iphone] GooglePlus SDK 라이브러리 링크 에러 "_OBJC_CLASS_$_CMMotionManager" (0) | 2014.01.21 |
[ObejctC]InterOP(ios 어플리케이션간 통신 방법) (0) | 2014.01.20 |
[ObjectC]ios Facebook SDK Login 구현 (0) | 2014.01.17 |
[ObjectC]object C 기본 문법 정리 (0) | 2014.01.10 |