Skip to content

Antondomashnev/ADFBRequestDialogViewController

Repository files navigation

ADFBRequestDialogViewController

UIViewController with FBDialog inside to send Facebook app request.

In API 2.0 Facebook changed me/friends endpoint, so according changelog:

Friend list now only returns friends who also use your app: The list of friends 
returned via the /me/friends endpoint is now limited to the list 
of friends that have authorized your app.

Therefore if our app isn't a game with canvas support we have only two options to invite user's Facebook friends to our app:

Message app is pretty nice, but requests dialog isn't good enough for me. It's pure UIWebView, so there are no customization options of top bar, buttons and showing animation. Thats why I've developed an ADFBRequestDialogViewController - view controller wrapper for requests dialog. With it you can customize top elements and present dialog whatever you want with iOS UIViewController custom transition.

Comparison

Adding ADFBRequestDialogViewController to your project

CocoaPods

CocoaPods is the recommended way to add ADFBRequestDialogViewController to your project.

  1. Add a pod entry for ADFBRequestDialogViewController to your Podfile pod 'ADFBRequestDialogViewController'
  2. Install the pod(s) by running pod install.
  3. Include ADFBRequestDialogViewController wherever you need it with #import "ADFBRequestDialogViewController.h".

Source files

Alternatively you can directly add the ADFBRequestDialogViewController.h and ADFBRequestDialogViewController.m source files to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop ADFBRequestDialogViewController.h and ADFBRequestDialogViewController.m onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
  3. Include ADFBRequestDialogViewController wherever you need it with #import "ADFBRequestDialogViewController.h".

Usage

Before start using ADFBRequestDialogViewController in code check if it can be presented with + (BOOL)canBePresented; static method. It it returns YES you can use this view controller otherwise use facebook method to present dialog.

The simplest way to present ADFBRequestDialogViewController is

ADFBRequestDialogViewController *vc = [[ADFBRequestDialogViewController alloc] initWithSession:[FBSession activeSession] message:@"YO" title:@"Invite friends" parameters:nil handler:nil];
[self presentViewController:vc animated:YES completion:nil];

There are some properties to initialize underlying FBDialog

@property (nonatomic, strong) FBSession *session;
@property (nonatomic, strong) NSString *message;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSDictionary *parameters;
@property (nonatomic, copy) FBWebDialogHandler handler;

There are UI elements for customization

@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *sendButton;
@property (nonatomic, strong) UIButton *cancelButton;

About

UIViewController with FBDialog to send Facebook app request inside

Resources

License

Stars

Watchers

Forks

Packages

No packages published