Skip to content

Social data tracking for iOS

Collecting social account data

The Braze iOS SDK does not automatically collect Facebook or Twitter user data. If you want to integrate Facebook user data in Braze user profiles, you need to fetch the user’s data and pass it to Braze.

Passing Facebook data to Braze

Initialize ABKFacebookUser objects with the Facebook data you have collected and pass it to Braze:

1
2
ABKFacebookUser *facebookUser = [[ABKFacebookUser alloc] initWithFacebookUserDictionary:self.facebookUserProfile numberOfFriends:self.numberOfFacebookFriends likes:self.facebookLikes];
[Appboy sharedInstance].user.facebookUser = facebookUser;
1
2
let facebookUser = ABKFacebookUser(facebookUserDictionary: facebookUserDictionary, numberOfFriends: numberOfFriends, likes: likes)
Appboy.sharedInstance()?.user.facebookUser = facebookUser

In ABKFacebookUser’s init method initWithFacebookUserDictionary:numberOfFriends:likes:, all the parameters should be dictionaries and arrays returned directly from Facebook:

Parameter Definition
facebookUserProfile The dictionary returned from the endpoint “/me”.
numberOfFriends The length of the friends array returned from the endpoint “/me/friends”.
likes The array of user’s Facebook likes from the endpoint “/me/likes”.

Refer to the Facebook Graph API for additional information.

Additionally, you can tailor what Facebook data you’re sending to Braze if you don’t want to include the entire basic profile. For example:

1
ABKFacebookUser *facebookUser = [[ABKFacebookUser alloc] initWithFacebookUserDictionary:facebookUserPublicProfile numberOfFriends:-1 likes:nil];  
1
let facebookUser = ABKFacebookUser(facebookUserDictionary: facebookUserDictionary, numberOfFriends: -1, likes:nil)

Refer to the Facebook SDK for more information.

Passing Twitter data to Braze

Initialize ABKTwitterUser objects, set up the Twitter data you have collected, and pass it to Braze:

1
2
3
4
ABKTwitterUser *twitterUser = [[ABKTwitterUser alloc] init];
twitterUser.userDescription = self.userDescription;
twitterUser.twitterID = self.twitterID;
[Appboy sharedInstance].user.twitterUser = twitterUser;
1
2
3
4
let twitterUser = ABKTwitterUser()
twitterUser.userDescription = twitterDserDescription
twitterUser.twitterID = twitterID
Appboy.sharedInstance()?.user.twitterUser = twitterUser
WAS THIS PAGE HELPFUL?
New Stuff!