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.
CocoaPods is the recommended way to add ADFBRequestDialogViewController to your project.
pod 'ADFBRequestDialogViewController'
pod install
.#import "ADFBRequestDialogViewController.h"
.Alternatively you can directly add the ADFBRequestDialogViewController.h
and ADFBRequestDialogViewController.m
source files to your project.
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.#import "ADFBRequestDialogViewController.h"
.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;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。