SDKの置き場所
インストールまで
参考
Getting Started with the Google+ Platform for iOS
ファイルをコピペする
- OpenSourceファイル
- GoogleOpenSource.framework
- GooglePlus.bundle
- GooglePlus.framework
の4点
frameworkを追加する
- GooglePlus.framework
- GooglePlus.bundle
- GoogleOpenSource.framework
と
- SystemConfiguration.framework
- Security.framework
- CoreGraphics.framework
- CoreMotion.framework
最低限この辺
ARC対応していないので
You need to disable "Automatic Reference Counting" for select files in the Google+ iOS SDK. Navigate to your project's settings, click Targets > Build Phases > and add the -fno-objc-arc compiler flag for every open source dependency provided by the Google+ iOS SDK.
Build Phase>Compile Sources でGTM〜とGTL〜なファイルに「-fno-objc-arc」をつけていく。
アプリのOAuth認証
参考
OAuth認証の準備
- Google Developers ConsoleのAPIと認証>API
Google+ APIを有効にする - Google Developers ConsoleのAPIと認証>認証情報
OAuthからアプリのBundle IDでClient IDを発行する。
アプリのOAuth認証
AppDelegate.m
//インポートして
# import <GooglePlus/GooglePlus.h>
...
//Delegateつけて
@interface AppDelegate () <GPPDeepLinkDelegate>
@end
...
//Client IDをいれて
static NSString * const kClientId = @"YOUR_CLIENT_ID";
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Client IDつっこんで認証
[GPPSignIn sharedInstance].clientID = kClientID;
// Read Google+ deep-link data.
[GPPDeepLink setDelegate:self];
[GPPDeepLink readDeepLinkAfterInstall];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
# pragma mark - GPPDeepLinkDelegate
- (void)didReceiveDeepLink:(GPPDeepLink *)deepLink {
// An example to handle the deep link data.
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Deep-link Data"
message:[deepLink deepLinkID]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
シェア
とりあえずiOSのSafari経由で
xxxViewController.m
//適当なユーザーアクション
- (IBAction)shareButtonTapped:(id)sender {
//useNativeSharebox
//id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
//not useNativeSharebox
id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
[shareBuilder setPrefillText:@"hello world"];
[shareBuilder setURLToShare:[NSURL URLWithString:@"http://apple.com"]];
[shareBuilder open];
}
Safariが立ち上がってGoogle+認証通ってシェア投稿画面に。