Share
[Player Network SDK & MSDK]
Shares a message to the user's feed, such as a Facebook timeline. If the user is already logged in, the channel parameter can be left empty.
System channel supports sharing text, links, and images at the same time. For the System channel, the sharing screen provided by the OS is opened for the user to share the content to an installed app that has implemented the system share function.
Supported Platform
- Unity
- Unreal Engine
Android, iOS, Windows
platform.Android, iOS, Windows
platform.MSDK currently does not support Windows.
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
Parameter | Type | Description |
---|---|---|
info | GUAFriendReqInfo | Friend module request body Including the request object, request information, and other important parameters. |
channel | string | Channel definition Example: "Facebook" |
Parameter | Type | Description |
---|---|---|
req_info | GUAFriendReqInfo | Friend module request body Including the request object, request information, and other important parameters. |
channel | std::string | Channel definition Example: "Facebook" |
Callback Processing
The callback processing API is GUAFriendBaseResultObserver. The callback data structure is GUABaseResult.
- Unity
- Unreal Engine
The callback event is FriendBaseEvents.
The callback methodID is GUA_FRIEND_SHARE
.
The callback event is OnBaseResultNotify.
The callback methodID is kMethodIDFriendShare
.
Code Sample
See 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 links, supports Facebook and System
var reqInfo = new GUAFriendReqInfo
{
Type = FriendReqType.Friend_REQ_LINK,
Link = "https://www.facebook.com/link"
};
UnionAdapterAPI.GetFriendService().Share(reqInfo);
(3) Share pictures, supports Facebook and 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 simultaneously, 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 videos, 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 links, supports Facebook and System
GUAFriendReqInfo reqInfo;
reqInfo.type = (int)GUA_NAMESPACE::kFriendReqTypeLink;
reqInfo.link = "https://www.facebook.com/link";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);
(3) Share pictures, supports Facebook and 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 text, link, and image simultaneously, supports Facebook and System
GUAFriendReqInfo reqInfo ;
reqInfo.type = (int)GUA_NAMESPACE::kFriendReqTypeInvite;
reqInfo.link = "https://www.facebook.com/link";
GUA_NAMESPACE::GUAFriendService::Share(reqInfo);
(5) Share videos
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 simultaneously, 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);