示例#1
0
 /// <summary>
 /// 分享游戏
 /// </summary>
 /// <param name="shareInfo"></param>
 /// <param name="callback"></param>
 public static void Share(GPlayShareParams shareInfo, ActionCallback callback)
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         if (shareInfo == null || callback == null)
         {
             LogErrorFormat("GPlaySDK.Share", "shareInfo or callback is null!!");
             return;
         }
         string shareInfoJson = ShareParams2String(shareInfo);
         //string shareInfoJson = JsonConvert.SerializeObject(shareInfo);
         int callbackid = ActionCallbackManager.Instance.AddCallback(callback);
         share(callbackid, shareInfoJson);
     }
 }
示例#2
0
        private static string ShareParams2String(GPlayShareParams gplayShareParams)
        {
            StringBuilder shareJson = new StringBuilder("{\"url\":\"");

            shareJson.Append(gplayShareParams.pageUrl);
            shareJson.Append("\",\"title\":\"");
            shareJson.Append(gplayShareParams.title);
            shareJson.Append("\",\"text\":\"");
            shareJson.Append(gplayShareParams.content);
            shareJson.Append("\",\"img_url\":\"");
            shareJson.Append(gplayShareParams.imgUrl);
            shareJson.Append("\",\"imgTitle\":\"");
            shareJson.Append(gplayShareParams.imgTitle);
            shareJson.Append("\"}");
            return(shareJson.ToString());
        }