FBSDKTestUsersManager

Provides methods for managing test accounts for testing Facebook integration.

Discussion:

Facebook allows developers to create test accounts for testing their applications' Facebook integration (see https://developers.facebook.com/docs/test_users/). This class simplifies use of these accounts for writing tests. It is not designed for use in production application code. This class will make Graph API calls on behalf of your app to manage test accounts and requires an app id and app secret. You will typically use this class to write unit or integration tests. Make sure you NEVER include your app secret in your production app.

Superclass:NSObject
Declared in:FBSDKTestUsersManager.h
类方法
sharedInstanceForAppID:appSecret:

Construct or return the shared instance

参数描述
appID

The Facebook app id

appSecret

The Facebook app secret

+ (instancetype)
sharedInstanceForAppID: (NSString *)appID
appSecret: (NSString *)appSecret;
声明语言: FBSDKTestUsersManager.h
实例方法
addTestAccountWithPermissions:completionHandler:

Add a test account with the specified permissions

参数描述
permissions

The set of permissions, e.g., [NSSet setWithObjects:@"email", @"user_friends"]

handler

The callback handler

- (void)
addTestAccountWithPermissions: (NSSet *)permissions
completionHandler: (FBSDKTestUsersManagerRetrieveTestAccountTokensHandler)handler;
声明语言: FBSDKTestUsersManager.h
makeFriendsWithFirst:second:callback:

Make two test users friends with each other.

参数描述
first

The token of the first user

second

The token of the second user

callback

The callback handler

- (void)
makeFriendsWithFirst: (FBSDKAccessToken *)first
second: (FBSDKAccessToken *)second
callback: (void(^)(NSError *))callback;
声明语言: FBSDKTestUsersManager.h
removeTestAccount:completionHandler:

Remove a test account for the given user id

参数描述
userId

The user id

handler

The callback handler

- (void)
removeTestAccount: (NSString *)userId
completionHandler: (FBSDKTestUsersManagerRemoveTestAccountHandler)handler;
声明语言: FBSDKTestUsersManager.h
requestTestAccountTokensWithArraysOfPermissions:createIfNotFound:completionHandler:

Retrieve FBSDKAccessToken instances for test accounts with the specific permissions.

参数描述
arraysOfPermissions

An array of permissions sets, such as @[ [NSSet setWithObject:@"email"], [NSSet setWithObject:@"user_birthday"]] if you needed two test accounts with email and birthday permissions, respectively. You can pass in empty nested sets if you need two arbitrary test accounts. For convenience, passing nil is treated as @[ [NSSet set] ] for fetching a single test user.

createIfNotFound

If YES, new test accounts are created if no test accounts existed that fit the permissions requirement

handler

The callback to invoke which will return an array of FBAccessTokenData instances or an NSError. If param createIfNotFound is NO, the array may contain [NSNull null] instances.

- (void)
requestTestAccountTokensWithArraysOfPermissions: (NSArray *)arraysOfPermissions
createIfNotFound: (BOOL)createIfNotFound
completionHandler: (FBSDKTestUsersManagerRetrieveTestAccountTokensHandler)handler;
Discussion:

If you are requesting test accounts with differing number of permissions, try to order arrayOfPermissionsArrays so that the most number of permissions come first to minimize creation of new test accounts.

声明语言: FBSDKTestUsersManager.h
Typedef
FBSDKTestUsersManagerRemoveTestAccountHandler

Callback block for removing a test user.

typedef void (^FBSDKTestUsersManagerRemoveTestAccountHandler)(
NSError *error);
声明语言: FBSDKTestUsersManager.h
FBSDKTestUsersManagerRetrieveTestAccountTokensHandler

Callback block for returning an array of FBSDKAccessToken instances (and possibly NSNull instances); or an error.

typedef void (^FBSDKTestUsersManagerRetrieveTestAccountTokensHandler)(
NSArray *tokens,
NSError *error);
声明语言: FBSDKTestUsersManager.h