LoginSignup
9
9

More than 5 years have passed since last update.

Google+ Platform on iOS のプロジェクトへのインストール

Last updated at Posted at 2014-02-06

SDKの置き場所

Google+ Platform on iOS

インストールまで

参考

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認証

参考

Google+ Sign-In for iOS

OAuth認証の準備

  1. Google Developers ConsoleのAPIと認証>API Google+ APIを有効にする
  2. 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+認証通ってシェア投稿画面に。

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9