iOS SDK Version

FBSDKProfile

@interfaceFBSDKProfile:NSObject<NSCopying,NSSecureCoding>
Represents an immutable Facebook profile
This class provides a global “currentProfile” instance to more easily add social context to your application. When the profile changes, a notification is posted so that you can update relevant parts of your UI and is persisted to NSUserDefaults.
Typically, you will want to call enableUpdatesOnAccessTokenChange:YES so that it automatically observes changes to the [FBSDKAccessToken currentAccessToken].
You can use this class to build your own FBSDKProfilePictureView or in place of typical requests to “/me”.
  • Unavailable
    Undocumented

    Declaration

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

    Declaration

    Objective-C
    +(instancetype)newNS_UNAVAILABLE;
  • initializes a new instance.

    Declaration

    Objective-C
    -(nonnullinstancetype)initWithUserID:(nonnullNSString*)userIDfirstName:(nullableNSString*)firstNamemiddleName:(nullableNSString*)middleNamelastName:(nullableNSString*)lastNamename:(nullableNSString*)namelinkURL:(nullableNSURL*)linkURLrefreshDate:(nullableNSDate*)refreshDate;
    Swift
    init(userID:String,firstName:String?,middleName:String?,lastName:String?,name:String?,linkURL:URL?,refreshDate:Date?)

    Parameters

    userID
    the user ID
    firstName
    the user’s first name
    middleName
    the user’s middle name
    lastName
    the user’s last name
    name
    the user’s complete name
    linkURL
    the link for this profile
    refreshDate
    the optional date this profile was fetched. Defaults to [NSDate date].
  • The current profile

    Declaration

    Objective-C
    @property(class,nonatomic,strong,readwrite,nullable)FBSDKProfile*currentProfile;
    Swift
    classvarcurrent:Profile?{getset}
  • The user id

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly)NSString*_NonnulluserID;
    Swift
    varuserID:String{get}
  • The user’s first name

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly,nullable)NSString*firstName;
    Swift
    varfirstName:String?{get}
  • The user’s middle name

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly,nullable)NSString*middleName;
    Swift
    varmiddleName:String?{get}
  • The user’s last name

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly,nullable)NSString*lastName;
    Swift
    varlastName:String?{get}
  • The user’s complete name

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly,nullable)NSString*name;
    Swift
    varname:String?{get}
  • A URL to the user’s profile.
    Consider using FBSDKAppLinkResolver to resolve this to an app link to link directly to the user’s profile in the Facebook app.

    Declaration

    Objective-C
    @property(nonatomic,readonly,nullable)NSURL*linkURL;
    Swift
    varlinkURL:URL?{get}
  • The last time the profile data was fetched.

    Declaration

    Objective-C
    @property(nonatomic,readonly)NSDate*_NonnullrefreshDate;
    Swift
    varrefreshDate:Date{get}
  • Indicates if currentProfile will automatically observe FBSDKAccessTokenDidChangeNotification notifications
    If observing, this class will issue a graph request for public profile data when the current token’s userID differs from the current profile. You can observe FBSDKProfileDidChangeNotification for when the profile is updated.
    Note that if [FBSDKAccessToken currentAccessToken] is unset, the currentProfile instance remains. It’s also possible for currentProfile to return nil until the data is fetched.

    Declaration

    Objective-C
    +(void)enableUpdatesOnAccessTokenChange:(BOOL)enable;
    Swift
    classfuncenableUpdatesOnAccessTokenChange(_enable:Bool)

    Parameters

    enable
    YES is observing
  • Loads the current profile and passes it to the completion block.
    If the profile is already loaded, this method will call the completion block synchronously, otherwise it will begin a graph request to update currentProfile and then call the completion block when finished.

    Declaration

    Objective-C
    +(void)loadCurrentProfileWithCompletion:(nullableFBSDKProfileBlock)completion;
    Swift
    classfuncloadCurrentProfile(completion:ProfileBlock?=nil)

    Parameters

    completion
    The block to be executed once the profile is loaded
  • A convenience method for returning a complete NSURL for retrieving the user’s profile image.

    Declaration

    Objective-C
    -(nullableNSURL*)imageURLForPictureMode:(FBSDKProfilePictureMode)modesize:(CGSize)size;
    Swift
    funcimageURL(forModemode:Profile.PictureMode,size:CGSize)->URL?

    Parameters

    mode
    The picture mode
    size
    The height and width. This will be rounded to integer precision.
  • Returns YES if the profile is equivalent to the receiver.

    Declaration

    Objective-C
    -(BOOL)isEqualToProfile:(nonnullFBSDKProfile*)profile;
    Swift
    funcisEqual(toprofile:Profile)->Bool

    Parameters

    profile
    the profile to compare to.