Hive provides a list of Hive friends, sends Hive messages between friends, and invites friends. Those functions listed below can be performed by the user on the Hive homepage, and you can also provide them within the game using the Hive API.
Searching Hive Friend Lists
You must specify the types of friends when you request the Hive friend lists. Select the array type among friends types below, and then set the array type as a parameter to implement getFriends()
method in the SocialHive class. User can get the friend lists as a result.
- Hive friends installed the game which the user currently plays:
FriendType.IN_GAME
- Hive friends not installed the game which the user currently plays:
FriendType.OUT_GAME
- Hive friends inviting to the game which the user currently plays:
FriendType.INVITED
- All Hive friends:
FriendType.ALL_GAME
Followings are sample codes to search the list of friends playing the same game.
API Reference: hive.SocialHive.getFriends
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Set the type of Hive friends to search. FriendType friendType = FriendType.IN_GAME; // Callback handler managing the result of searching Hive friends list. public void onFriendsHiveCB(ResultAPI result, List<ProfileHive> profileList) { if(result.isSuccess() && profileList != null ){ foreach(ProfileHive profile in profileList) { // Implement to search the Hive friends list. } } } // Search the Hive friends list. hive.SocialHive.getFriends(friendType, onFriendsHiveCB); |
API Reference: SocialHive::getFriends
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Set the type of Hive friends to search. FriendType friendType = FriendType::IN_GAME; // Search the Hive friends list. SocialHive::getFriends(friendType, [=](ResultAPI result, std::vector<ProfileHive> profileList){ // Callback function managing the result of searching Hive friends list. if(result.isSuccess() && profileList != nullptr) { for(ProfileHive profile : profileList){ // Implement to search the Hive friends list. } } }); |
API Reference: com.hive.SocialHive.getFriends
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Set the type of Hive friends to search. FriendType friendType = FriendType.IN_GAME; // Search the Hive friends list. SocialHive.getFriends(friendType, new SocialHive.ProfileListener() { @Override public void onProfile(ResultAPI result, List<ProfileHive> profileList) { // Callback listener managing the result of searching Hive friends list. if(result.isSuccess() && profileList != null) { for (ProfileHive profile : profileList) { // Implement to search the Hive friends list. } } } }); |
API Reference: HIVESocialHive:getFriends
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Set the type of Hive friends to search. HIVEFriendType friendType = kHIVEFriendTypeIN_GAME; // Search the Hive friends list. [HIVESocialHive getFriends:friendType handler:^(HIVEResultAPI *result, NSArray<HIVEProfileHive *> *profileList) { // Callback handler managing the result of searching Hive friends list. if([result isSuccess] && profileList != nil) { for (HIVEProfileHive *profile in profileList) { // Implement to search the Hive friends list. } } }]; |
Inviting Hive Friends
A Hive friend is a relationship that is made through the user’s address book, Facebook interlock, or Hive friend request and acceptance.
To display friend lists for sending invitations, see Searching Hive Friend Lists section.
To send invitations to Hive friends, implement sendInvitationMessage()
method in the SocialHive class and ensure to deliver MessageContent object as the first parameter of this function.
API Reference: hive.SocialHive.sendInvitationMessage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Set an invitation message to Hive. MessageContent messageContent = new MessageContent(); messageContent.vid = "VID"; messageContent.message = "Invitation message"; // Callback handler managing the result of sending Hive invitation message. public void onSendMessageHiveCB(ResultAPI result) { if(result.isSuccess()){ // Success in API call. } } // Send the Hive invitation message. hive.SocialHive.sendInvitationMessage(messageContent, onSendMessageHiveCB); |
API Reference: SocialHive::sendInvitationMessage
1 2 3 4 5 6 7 8 9 10 11 12 |
// Set an invitation message to Hive. MessageContent content = new MessageContent(); content.vid = "VID"; content.message = "Invitation message"; // Send the Hive invitation message. SocialHive::sendInvitationMessage(content, [=](ResultAPI result){ // Callback function managing the result of sending Hive invitation message. if(result.isSuccess()){ // Success in API call. } }); |
API Reference: com.hive.SocialHive.sendInvitationMessage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Set an invitation message to Hive. MessageContent content = new MessageContent(); content.vid = "VID"; content.message = "Invitation message"; // Send the Hive invitation message. SocialHive.sendInvitationMessage(content, new SocialHive.SendMessageListener() { // Callback listener managing the result of sending Hive invitation message. @Override public void onSendMessage(ResultAPI result) { if(result.isSuccess()){ // Success in API call. } } }); |
API Reference: SocialHive:sendInvitationMessage
1 2 3 4 5 6 7 8 9 10 11 12 |
// Set an invitation message to Hive. HIVEMessageContent content = [[HIVEMessageContent alloc] init]; content.vid = @"VID"; content.message = @"Invitation message"; // Send the Hive invitation message. [HIVESocialHive sendInvitationMessage:content handler:^(HIVEResultAPI *result) { // Callback handler managing the result of sending Hive invitation message. if([result isSuccess]){ // Success in API call. } }]; |
Sending Messages to Hive Friends
When user sends a message to Hive friend, Hive sends push notification to the message receiver. The medium of notification on receiver’s device is one of follows:
- The game which sender delivers messages from
- The game which receiver recently plays connected with Hive
Hive sends push notifications if users set to opt in the notifications on their device even when receivers does not play games. When the receiver gets a push notification and tap it, the relevant game starts. So, make sure to provide the UI which connects with Hive messages.
To send Hive messages, implement sendMessage()
method in the SocialHive class. Ensure that MessageContent object, sent to the first parameter from this method contains messages as well as additional information. Check the result of implementing sendMessage()
method through the callback function, onSendMessageHiveCB()
.
Followings are sample codes to send messages to Hive friends.
API Reference: hive.SocialHive.sendMessage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Set a Hive message. MessageContent messageContent = new MessageContent(); messageContent.vid = "VID"; messageContent.message = "Message"; // Callback handler managing the result of sending Hive message. public void onSendMessageHiveCB(ResultAPI result) { if(result.isSuccess()){ // Success in API call. } } // Send the Hive message. hive.SocialHive.sendMessage(messageContent, onSendMessageHiveCB); |
API Reference: SocialHive::sendMessage
1 2 3 4 5 6 7 8 9 10 11 12 |
// Set a Hive message. MessageContent content = new MessageContent(); content.vid = "VID"; content.message = "Message"; // Send the Hive message. SocialHive::sendMessage(content, [=](ResultAPI result){ // Callback function managing the result of sending Hive message. if(result.isSuccess()){ // Success in API call. } }); |
API Reference: com.hive.SocialHive.sendMessage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Set a Hive message. MessageContent content = new MessageContent(); content.vid = "VID"; content.message = "Message"; // Send the Hive message. SocialHive.sendMessage(content, new SocialHive.SendMessageListener() { // Callback listener managing the result of sending Hive message. @Override public void onSendMessage(ResultAPI result) { if(result.isSuccess()){ // Success in API call. } } }); |
API Reference: SocialHive:sendMessage
1 2 3 4 5 6 7 8 9 10 11 12 |
// Set a Hive message. HIVEMessageContent content = [[HIVEMessageContent alloc] init]; content.vid = @"VID"; content.message = @"Message"; // Send the Hive message. [HIVESocialHive sendMessage:content handler:^(HIVEResultAPI *result) { // Callback handler managing the result of sending Hive message. if([result isSuccess]){ // Success in API call. } }]; |
Displaying Message Badge
Design a message icon as you want and apply it to games to display ‘New’ badge. Check whether ‘New’ badge is required or not only when Hive message icon is displayed.
Badge Display Policy
Comply with the following policies to display and hide badges
- Display badges when: Unread new messages exist.
- Hide badges when: All messages are read. Reading a message means that user reads the message at the detail page. That is, checking message list is not considered as reading messages.
- Indicate badges: With capital letter N. Do not display the number of messages unread.
New message check
To display ‘New’ badge, check whether new messages exist. To check new messages, implement getBadgeInfo()
method in the SocialHive class. You can check the result of implementation through the callback function, onSocialBadge()
.
Followings are sample codes to check new messages.
API Reference: hive.SocialHive.getBadgeInfo
1 2 3 4 5 6 7 8 9 |
// Callback handler checking the existance of new message. public void onGetSocialBadgeCB(ResultAPI result, SocialBadge socialBadge) { if(result.isSuccess()){ // Success in API call. && New message exists. } } // Check whether new message exists. SocialHive.getBadgeInfo (onGetSocialBadgeCB); |
API Reference: SocialHive::getBadgeInfo
1 2 3 4 5 6 7 |
// Check whether new message exists. SocialHive::getBadgeInfo([=](ResultAPI result, SocialBadge socialBadge){ // Callback function checking the existance of new message. if(result.isSuccess()){ // Success in API call. && New message exists. } }); |
API Reference: com.hive.SocialHive.getBadgeInfo
1 2 3 4 5 6 7 8 9 10 |
// Check whether new message exists. SocialHive.getBadgeInfo(new SocialHive.SocialBadgeListener() { // Callback listener checking the existance of new message. @Override public void onSocialBadge(ResultAPI result, SocialBadge badge) { if(result.isSuccess()){ // Success in API call. && New message exists. } } }); |
API Reference: SocialHive:getBadgeInfo
1 2 3 4 5 6 7 |
// Check whether new message exists. [HIVESocialHive getBadgeInfo:^(HIVEResultAPI *result, HIVESocialBadge *badge) { // Callback handler checking the existance of new message. if([result isSuccess]){ // Success in API call. && New message exists. } }]; |
Reference: MessageContent class
Name | Type | Description | Required |
vid | String | Message receiver’s VID
Ensure to define |
Optional |
uid | String | Message receiver’s UID | Optional |
message | String(512) | The contents of message. Unlimited language | Required |
imageUrl | String | Image URL attached in messages | Optional |
thumbnailUrl | String | Thumbnail URL attached in messages. It is required when imageUrl field is input |
Optional |
usePush | Boolean | Push notification type to use the OS notification on device or not
|
Optional |