Hive provides users a function to sync with Facebook account. By using Hive API, therefore, you can search user profile and friend lists on Facebook, help users send messages to Facebook friends, and help them post on Facebook News Feed.

Facebook functions are available when user signs in Facebook. If a user not signed in Facebook tries to use the Facebook functions, Hive Client displays a login page to sign in Facebook.

Facebook Profile

To search user’s Facebook profile data, implement getMyProfile() method in the SocialFacebook class. The data is returned as a part of ProfileFacebook list.

Unity®

API Reference: hive.SocialFacebook.getMyProfile

C++

API Reference: SocialFacebook::getMyProfile

Android

API Reference: com.hive.SocialFacebook.getMyProfile

iOS

API Reference: HIVESocialFacebook:getMyProfile

Searching Friends List on Facebook

Implement getFriends() method in the SocialFacebook class to search the list of user’s Facebook friends.
Followings are sample codes to search the friends list on Facebook.

Unity®

API Reference: hive.SocialFacebook.getFriends

C++

API Reference: SocialFacebook::getFriends

Android

API Reference: com.hive.SocialFacebook.getFriends

iOS

API Reference: HIVESocialFacebook:getFriends

Inviting Facebook Friends

Users synced Hive with Facebook account can invite Facebook friends to the game that a user currently plays. To display invitation page, implement showInvitationDialog() method in the SocialFacebook class.

FacebookMessage object, sent to the parameter of method contains recipients, dialog title and message field. As Facebook processes the information about recipients, Hive does not know the relevant data. Therefore, empty the recipients field when sending to the parameter. It is recommended to empty the field because Facebook may misunderstand the message as a spam due to the contents of dialog title or messages.

Followings are sample codes to send invitations to user’s Facebook friends.

Unity®

API Reference: hive.SocialFacebook.showInvitationDialog

C++

API Reference: SocialFacebook::showInvitationDialog

Android

API Reference: com.hive.SocialFacebook.showInvitationDialog

iOS

API Reference: HIVESocialFacebook:showInvitationDialog

Sending Messages to Facebook Friends

Implement sendMessageFacebook() method in the SocialFacebook class to send messages to user’s Facebook friends. Make sure that the FacebookMessage object, sending to the first parameter of the method contains messages and additional information.

Followings are sample codes to send messages to one of Facebook friends

Unity®

API Reference: hive.SocialFacebook.sendMessageFacebook

C++

API Reference: SocialFacebook::sendMessageFacebook

Android

API Reference: com.hive.SocialFacebook.sendMessageFacebook

iOS

API Reference: HIVESocialFacebook:sendMessageFacebook

Writing Posts on News Feed

Hive provides a posting function as a method of advertising games. This function is available to post your News Feed on user’s Facebook Feed. News Feed is composed of title, posting and image. You can set a linked page when user taps the content.

Posting format on Facebook depends on the attaching image size. The recommended size is as follows. For more information about image size, see Facebook Developers site.

  • Size: Bigger than 600×315 pixels
  • Image aspect ratio: 1.91:1 (width:height. Opposite for vertical image)

Implement postFacebookWithContentURL() method in the SocialFacebook class for users to post News Feed. Make sure that the contentURL(string), sending to the first parameter of the method contains contents URL which you want to write postings on News Feed.

Followings are sample codes to display editing page to post News Feed and write comments on Facebook.

Unity®

API Reference: hive.SocialFacebook.postFacebookWithContentURL

C++

API Reference: SocialFacebook::postFacebookWithContentURL

Android

API Reference: com.hive.SocialFacebook.postFacebookWithContentURL

iOS

API Reference: HIVESocialFacebook::postFacebookWithContentURL:handler:

Reference: Main Class to Use Facebook Functions

Followings are the necessary object to implement SocialFacebook API which is available to use Facebook functions.

ProfileFacebook Class

ProfileFacebook class defines user’s Facebook profile, synced with the Facebook account, and the profile data is composed of the following information.

Name Type Description Returned
uid String App-scoped User ID issued by Facebook Always
email String User’s email on Facebook Provided when user sets an authority to share the user email on Facebook
username String User name on Facebook Optional
profileImageUrl String User profile image URL on Facebook Optional

FacebookMessage Class

FacebookMessage class defines Facebook messages toward friends.

Name Type Description Required
recipients String list

  • Unity®: List
  • C++: std::vector<std::string>
  • Android: String []
  • iOS: <NSArray *>  *
ID lists of Facebook friends to send messages
CAUTION. Send the empty message in case of invitation
Required
dialogTitle String(50) The title of dialog box Optional
message String Message contents Optional
data String(255) Hidden data sending with messages Optional