Share (Share)
[Player Network SDK & MSDK]
Send a message to a specified friend. If already logged in, the channel parameter can be left empty.
When the channel is System, the system share menu will open, allowing the user to choose to share content to the corresponding app, which must support system sharing. When the channel is System, text, links, and images can be shared simultaneously.
Supported Platforms
- Unity
- Unreal Engine
Android, iOS, Windows platform.Android, iOS, Windows platform.MSDK does not support Windows yet
Function Definition
- Unity
- Unreal Engine
void Share(GUAFriendReqInfo info, string channel = "");
static bool Share(const GUAFriendReqInfo &req_info, const std::string &channel = "");
Input Parameters
- Unity
- Unreal Engine
| Parameters | Type | Description |
|---|---|---|
| Description | Friend Request (GUAFriendReqInfo) | Friend Module Request Structure Primarily includes the request object, request information, and other essential input parameters |
| channel | string | Channel information Such as "Facebook" |
| Parameters | Type | Description |
|---|---|---|
| req_info | Friend Request (GUAFriendReqInfo) | Friend Module Request Structure Primarily includes the request object, request information, and other essential input parameters |
| channel | std::string | Channel information Such as "Facebook" |
Callback Handling
The callback handler interface is GUAFriendBaseResultObserver.The callback data structure is GUABaseResult.
- Unity
- Unreal Engine
The callback event is FriendBaseEvents. The callback ID is GUA_FRIEND_SHARE.
The callback event is OnBaseResultNotify. Callback ID is kMethodIDFriendShare.
Code Example
Refer to the enumeration structure GUAFriendReqType.
- Unity
- Unreal Engine
(1) Share text, supports System
var reqInfo = new GUAFriendReqInfo
{
Type = FriendReqType.Friend_REQ_TEXT,
Description = "description"
};
UnionAdapterAPI.GetFriendService().Share(reqInfo);
(2) Share link, supports Facebook, System
var reqInfo = new GUAFriendReqInfo
{
Type = FriendReqType.Friend_REQ_LINK,
Link = "https://www.facebook.com/link"
};
UnionAdapterAPI.GetFriendService().Share(reqInfo);
(3) Share image, supports Facebook, System
var reqInfo = new GUAFriendReqInfo
{
Type = FriendReqType.Friend_REQ_IMAGE,
ImagePath = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
};
UnionAdapterAPI.GetFriendService().Share(reqInfo);
(4) Share text, link and image, supports System
var reqInfo = new GUAFriendReqInfo
{
Type = FriendReqType.Friend_REQ_IMAGE,
Description = "INTL Description",
Link = "https://www.facebook.com/link",
ImagePath = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
};
UnionAdapterAPI.GetFriendService().Share(reqInfo);
(5) Share video, supports Facebook
var reqInfo = new GUAFriendReqInfo
{
Type = FriendReqType.Friend_REQ_VIDEO,
MediaPath = "/path/to/video"
};
UnionAdapterAPI.GetFriendService().Share(reqInfo);
(1) Share text, supports System
GUAFriendReqInfo reqInfo;
reqInfo.type = (int)GUA_NAMESPACE::kGUAFriendReqTypeText;
reqInfo.description = "description";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);
(2) Share link, supports Facebook, System
GUAFriendReqInfo reqInfo;
reqInfo.type = (int)GUA_NAMESPACE::kFriendReqTypeLink;
reqInfo.link = "https://www.facebook.com/link";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);
(3) Share image, supports Facebook, System
GUAFriendReqInfo reqInfo;
reqInfo.type = (int)GUA_NAMESPACE::kFriendReqTypeImage;
reqInfo.image_path = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);
(4) Share invitation, supports Facebook, System
GUAFriendReqInfo reqInfo ;
reqInfo.type = (int)GUA_NAMESPACE::kFriendReqTypeInvite;
reqInfo.link = "https://www.facebook.com/link";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);
(5) Share Video
GUAFriendReqInfo reqInfo;
reqInfo.type = (int)GUA_NAMESPACE::kFriendReqTypeVideo;
reqInfo.media_path = "/path/to/video";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);
(6) Share text, link and image, supports System
GUAFriendReqInfo reqInfo;
reqInfo.type = (int)GUA_NAMESPACE::kFriendReqTypeImage;
reqInfo.description = "INTL Service";
reqInfo.link = "https://www.facebook.com/link";
reqInfo.image_path = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);