Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 145 lines (82 sloc) 6.709 kb

GetGlue iPhone Check-in Widget

Objective-C wrapper for GetGlue Check-in widgets

The simplest way to use the GetGlue Check-in widget is to simply add the code directly to your project. Check-in widgets can then be created either in interface builder, or directly in code. You can see an example of both of these methods in the "Example" project which is provided.

Adding the code to your project

  1. Drag the entire "GetGlueWidget" in the src directory into your project

  2. If you do not want to maintain an external refference to the "GetGlueWidget" directory, you can check "Copy items into destination group's folder (if needed)"

    Copy items dialog

At this point, your project should compile successfuly, and you are ready to create a GetGlue widget in your application.

Creating a widget in code

  1. include the GetGlue header

    #import "GetGlueWidget.h"
    
  2. Create an instance of a GetGlue widget, setting the X and Y values where you would like your widget to appear (Note, GetGlue widgets are always 64x74, reguardles of what width and height are passed in here):

    GetGlueWidgetView* gg2 = [[[GetGlueWidgetView alloc] initWithFrame:CGRectMake(20, 138, 64, 74)] autorelease];
    
  3. Set the objectKey of the widget to the GetGlue object key the widget should be associated with:

    gg2.objectKey = @"tv_shows/true_blood";
    
  4. Add the widget to your view:

    [self.view addSubview:gg2];
    

Creating a widget via interface builder

Note: even with widgets created in interface builder, code is still needed to set the GetGlue object key with which the widget is associated.

  1. Open the xib file that contains the view where you would like your widget to appear

  2. Search for "GetGlue" in the "Classes" tab of the "Library" winodw

    GetGlue view

  3. Drag an instance of "GetGlueWidgetView" into your view.

  4. With the new GetGlueWidgetView selected, set width to 64 and height to 74 in the "Size" tab of the inspector

    Size inspector

  5. Position the view where you would like your widget to appear

    ![position widget](http://glueimg.s3.amazonaws.com/widgets/docs/4.png

  6. You may wish to set the background color of your widget, or make it ransparent, you can do this from the "Attributes" tab of the inspector

    attributes

  7. Add an "GetGlueWidgetView" outlet to your xib's view controller (dont forget to import GetGlueWidget.h)

    #import "GetGlueWidget.h"
    
    @interface ExampleViewController : UIViewController {
        GetGlueWidgetView* gg;
    }
    
    @property (nonatomic, retain) IBOutlet GetGlueWidgetView *gg;
    
  8. In interface builder select your nib's View Controller, and in the "Connections" tab of the inspector, drag a connection from your outlet to the view you created in step 3

    connect outlet

  9. Set the widget's object key in your viewDidLoad

    - (void)viewDidLoad {
        [super viewDidLoad];
        gg.objectKey = @"tv_shows/true_blood";
    }
    

    at this point you may also set a custom source url that will be linked back to from the GetGlue stream. When setting source, be sure to set it before setting object key, like so:

    - (void)viewDidLoad {
        [super viewDidLoad];
        gg.source = @"http://www.hbo.com/true-blood/";
        gg.objectKey = @"tv_shows/true_blood";
    }
    

Advanced Fetaures

The GetGlue check-in widget has several more advanced features, to help integrate the widget into your application, which can be accessed by implimenting the GetGlueWidgetDelegate. The GetGlueWidgetDelegate has several callbacks.

- (void)widget:(GetGlueWidgetView*) widget didPerformCheckinForUser: (NSString*) username

Called after a user checks-in. username will be the GetGlue username of the user who checked in. The objectKey can be obtained from the widget (widget.objectKey)

- (void)widget:(GetGlueWidgetView*) widget didRecieveNewCheckinCount:(int) newCount

When the widget initially loads, or after a check-in, this method will be called with the number of total check-ins

- (BOOL)widget:(GetGlueWidgetView*) widget shouldLaunchURL:(NSURL*) url

By default, external URLs (such as object pages on getglue.com) are loaded in safari. If you wish to load these in a webview within your own app, you may return NO in this delegate, and launch url on your own.

Theming

Widgets can be themed to better integrate with their host application. Theme values are passed to the widget by providing a NSDictionary of theme keys and values, as in the example theme. Besides the theme values listed here, common theme elements are listed in the main widgets documentation.

loginBgColor sets the background color for main, login, and signup forms on the widget.

loginImage sets the background image for main logged-out screen that shows the login and Facebook Connect links.

logoStyle controls which logo is used in the border. Either dark or light is accepted to better match with the theme.

windowBgColor is the color of the top and bottom borders around the widget.

headerTextShadowColor controls color of the text shadow in the widget header on the check-in screen.

linkColor controls the default color of all links across the widget.

borderColor specifies the border color between stream items on the check-in screen, and the color of accent borders on other screens.

bodyBgColor is the background color of the stream on the check-in screen.

headerBgColor sets the background color of the heading on the check-in page, where the object image and stats are displayed.

headerTextColor sets the text color of the check-in page heading.

headerTextShadowColor controls the text shadow on the text above.

formBgColor is the background color of the check-in form.

Getting Help

If you have any problems integrating GetGlue widgets into your project, you can post to the GetGlue Development Group, or email us at support@getglue.com

Something went wrong with that request. Please try again.