Send message to specified friend (SendMessage)
[Player Network SDK & MSDK] Send a message to a specified friend. If already logged in, the channel parameter can be left empty.
Supported Platforms
- Unity
- Unreal Engine
Android, iOS, Windows platform.Android, iOS, Windows platform.MSDK currently does not support Windows
Function Definition
- Unity
- Unreal Engine
void SendMessage(GUAFriendReqInfo info, string channel = "");
static void SendMessage(const GUAFriendReqInfo &req_info, const std::string &channel = "");
Input Parameters
- Unity
- Unreal Engine
| Parameters | Type | Description |
|---|---|---|
| Description | Friend Request (GUAFriendReqInfo) | Friend Module Request Structure Mainly includes the request object, request information, and other important input parameters |
| channel | string | Channel information Such as "Facebook" |
| Parameters | Type | Description |
|---|---|---|
| Info | Friend Request (GUAFriendReqInfo) | Friend Module Request Structure Mainly includes the request object, request information, and other important input parameters |
| channel | std::string | Channel information Such as "Facebook" |
Callback Handling
The callback handling interface is GUAFriendBaseResultObserver.The callback data structure is GUABaseResult.
- Unity
- Unreal Engine
The callback event is FriendBaseEvents. The callback ID is GUA_FRIEND_SEND_MESSAGE.
The callback event is OnBaseResultNotify. Callback ID is kMethodIDFriendSendMessage.
Code Example
Refer to the enum structure GUAFriendReqType.
- Unity
- Unreal Engine
(1) Send Text
var reqInfo = new GUAFriendReqInfo
{
Type = GUAFriendReqType.Friend_REQ_TEXT,
Description = "INTL Service"
};
UnionAdapterAPI.GetFriendService().SendMessage(reqInfo);
(2) Send link, supports Facebook, Garena
var reqInfo = new GUAFriendReqInfo
{
Type = GUAFriendReqType.Friend_REQ_LINK,
Link = "https://www.facebook.com/link"
};
UnionAdapterAPI.GetFriendService().SendMessage(reqInfo);
(3) Send image, supports Facebook, Garena
var reqInfo = new GUAFriendReqInfo
{
Type = GUAFriendReqType.Friend_REQ_IMAGE,
ImagePath = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
};
UnionAdapterAPI.GetFriendService().SendMessage(reqInfo);
(4) Send invitation, supports Facebook, Garena, Discord
var reqInfo = new GUAFriendReqInfo
{
Type = GUAFriendReqType.Friend_REQ_INVITE,
Link = "https://www.facebook.com/link";
};
UnionAdapterAPI.GetFriendService().SendMessage(reqInfo);
(5) Send Video
var reqInfo = new GUAFriendReqInfo
{
Type = GUAFriendReqType.Friend_REQ_VIDEO,
MediaPath = "/path/to/video"
};
UnionAdapterAPI.GetFriendService().SendMessage(reqInfo);
(1) Send Text
GUAFriendReqInfo reqInfo;
reqInfo.type = (int32)GUAFriendReqType::kReqText;
reqInfo.description = "INTL Service";
GUA_NAMESPACE::GUAFriendService::SendMessage(reqInfo);
(2) Send link, supports Facebook, Garena
GUAFriendReqInfo reqInfo;
reqInfo.type = (int32)GUAFriendReqType::kReqLink;
reqInfo.link = "https://www.facebook.com/link";
GUA_NAMESPACE::GUAFriendService::SendMessage(reqInfo);
(3) Send image, supports Facebook, Garena
GUAFriendReqInfo reqInfo;
reqInfo.type = (int32)GUAFriendReqType::kReqImage;
reqInfo.image_path = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
GUA_NAMESPACE::GUAFriendService::SendMessage(reqInfo);
(4) Send invitation, supports Facebook, Garena, Discord
GUAFriendReqInfo reqInfo;
reqInfo.type = (int32)GUAFriendReqType::kReqInvite;
reqInfo.Link = "https://www.facebook.com/link";
GUA_NAMESPACE::GUAFriendService::SendMessage(reqInfo);
(5) Send Video
GUAFriendReqInfo reqInfo;
reqInfo.type = (int32)GUAFriendReqType::kReqVideo;
reqInfo.media = "/path/to/video";
GUA_NAMESPACE::GUAFriendService::SendMessage(reqInfo);