iOS SDK Version

FBSDKTestUsersManager

@interfaceFBSDKTestUsersManager:NSObject
Provides methods for managing test accounts for testing Facebook integration.
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.
  • Unavailable
    Undocumented

    Declaration

    Objective-C
    -(instancetype)initNS_UNAVAILABLE;
  • Unavailable
    Undocumented

    Declaration

    Objective-C
    +(instancetype)newNS_UNAVAILABLE;
  • construct or return the shared instance

    Declaration

    Objective-C
    +(nonnullinstancetype)sharedInstanceForAppID:(nonnullNSString*)appIDappSecret:(nonnullNSString*)appSecret;
    Swift
    classfuncshared(forAppIDappID:String,appSecret:String)->Self

    Parameters

    appID
    the Facebook app id
    appSecret
    the Facebook app secret
  • retrieve FBSDKAccessToken instances for test accounts with the specific permissions.
    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.

    Declaration

    Objective-C
    -(void)requestTestAccountTokensWithArraysOfPermissions:(nonnullNSArray<NSSet<NSString*>*>*)arraysOfPermissionscreateIfNotFound:(BOOL)createIfNotFoundcompletionHandler:(nullableFBSDKAccessTokensBlock)handler;
    Swift
    funcrequestTestAccountTokens(withPermissionsarraysOfPermissions:[Set<String>],createIfNotFound:Bool,completionHandlerhandler:AccessTokensBlock?=nil)

    Parameters

    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.
    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.
  • add a test account with the specified permissions

    Declaration

    Objective-C
    -(void)addTestAccountWithPermissions:(nonnullNSSet<NSString*>*)permissionscompletionHandler:(nullableFBSDKAccessTokensBlock)handler;
    Swift
    funcaddTestAccount(withPermissionspermissions:Set<String>,completionHandlerhandler:AccessTokensBlock?=nil)

    Parameters

    permissions
    the set of permissions, e.g., [NSSet setWithObjects:@“email”, @“user_friends”]
    handler
    the callback handler
  • remove a test account for the given user id

    Declaration

    Objective-C
    -(void)removeTestAccount:(nonnullNSString*)userIdcompletionHandler:(nullableFBSDKErrorBlock)handler;
    Swift
    funcremoveTestAccount(_userId:String,completionHandlerhandler:ErrorBlock?=nil)

    Parameters

    userId
    the user id
    handler
    the callback handler
  • Make two test users friends with each other.

    Declaration

    Objective-C
    -(void)makeFriendsWithFirst:(nonnullFBSDKAccessToken*)firstsecond:(nonnullFBSDKAccessToken*)secondcallback:(nullableFBSDKErrorBlock)callback;
    Swift
    funcmakeFriends(first:FBSDKAccessToken,second:FBSDKAccessToken,callback:ErrorBlock?=nil)

    Parameters

    first
    the token of the first user
    second
    the token of the second user
    callback
    the callback handler