bang
bang

Reputation: 84

after setup GData ios client in xcode4, can't use OAuth

I follow this blog to setup GData to my ios project, build success, everything is ok, but when I add a GTMOAuth2ViewControllerTouch view to my window, it just show a black view without anything. The code built GTMOAuth2ViewControllerTouch in my project was copy from http://code.google.com/p/gtm-oauth2/. In gtm-oauth2 project, the OAuth is work, I don't know why the same code can't work in my new project.

my code:

GDAppDelegate.h:

@interface GDAppDelegate : UIResponder <UIApplicationDelegate>{
@private
    UIWindow *_window;
    UINavigationController *mNavigationController;
}

@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) GDViewController *viewController;

@end

GDAppDelegate.m:

#import "GDAppDelegate.h"
#import "GData.h"
#import "GTMOAuth2SignIn.h"
#import "GTMOAuth2ViewControllerTouch.h"
@implementation GDAppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    UINavigationController *mainNavigationController = [[UINavigationController alloc] initWithRootViewController:nil];
    mainNavigationController.view.frame = CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-20);
    [mainNavigationController.navigationBar setBarStyle:UIBarStyleDefault];
    [mainNavigationController setToolbarHidden:YES];

    NSString *keychainItemName = nil;
    NSString *scope = @"https://www.googleapis.com/auth/plus.me";

    NSString *clientID = @"181779079861.apps.googleusercontent.com";//self.clientIDField.text;
    NSString *clientSecret = @"FAIi_4YiI3vAtYi7Xf1nMF7Q";//self.clientSecretField.text;


    SEL finishedSel = @selector(viewController:finishedWithAuth:error:);

    GTMOAuth2ViewControllerTouch *viewController;
    viewController = [GTMOAuth2ViewControllerTouch controllerWithScope:scope
                                                              clientID:clientID
                                                          clientSecret:clientSecret
                                                      keychainItemName:keychainItemName
                                                              delegate:self
                                                      finishedSelector:finishedSel];

    NSDictionary *params = [NSDictionary dictionaryWithObject:@"en"
                                                       forKey:@"hl"];
    viewController.signIn.additionalAuthorizationParameters = params;

    NSString *html = @"<html><body bgcolor=silver><div align=center>Loading sign-in page...</div></body></html>";
    viewController.initialHTMLString = html;


    self.window.rootViewController = viewController;

    [self.window makeKeyAndVisible];

    return YES;
}

Upvotes: 2

Views: 904

Answers (2)

Liron
Liron

Reputation: 2032

I had this same problem and had to include the GTMOAuth2ViewControllerTouch.xib file into my main solution. Otherwise, using the static library worked fine.

It seems that the .xib files have to be copied into the app's resources folder so that it can load them.

Upvotes: 0

bang
bang

Reputation: 84

I solved this problem by add GData and OAuth lib classes directly to my app

Upvotes: 1

Related Questions