コード例 #1
0
    static void SendInvite(string referralDataUrl,
                           Action completeCallback,
                           Action cancelCallback,
                           Action <GetSocialError> errorCallback)
    {
        GetSocialDebugLogger.D("Sharing link on Facebook : " + referralDataUrl);
        FB.Mobile.ShareDialogMode = ShareDialogMode.WEB;
        FB.ShareLink(new Uri(referralDataUrl), callback: result =>
        {
            // reopen GetSocialUi
            // because othewise it cannot deliever the result back to the app
            GetSocialUi.RestoreView();
            GetSocialDebugLogger.D("Sharing link finished: " + result);
            if (result.Cancelled)
            {
                cancelCallback();
                return;
            }
            if (!string.IsNullOrEmpty(result.Error))
            {
                var errorMsg = "Failed to share link: " + result.Error;
                Debug.LogError(errorMsg);
                errorCallback(new GetSocialError(errorMsg));
                return;
            }

            completeCallback();
        });
    }
コード例 #2
0
    static void SendInvite(string referralDataUrl,
                           Uri imageUrl,
                           Action completeCallback,
                           Action cancelCallback,
                           Action <GetSocialError> errorCallback)
    {
        GetSocialDebugLogger.D("Sending Facebook invite with URL: " + referralDataUrl);
        FB.Mobile.AppInvite(new Uri(referralDataUrl), imageUrl,
                            result =>
        {
#if UNITY_ANDROID && USE_GETSOCIAL_UI
            // Restore the hidden view after we have received the result
            GetSocialUi.RestoreView();
#endif

            GetSocialDebugLogger.D("Sending invite finished: " + result);
            if (result.Cancelled)
            {
                cancelCallback();
                return;
            }
            if (!string.IsNullOrEmpty(result.Error))
            {
                var errorMsg = "Failed sending app invite: " + result.Error;
                Debug.LogError(errorMsg);
                errorCallback(new GetSocialError(errorMsg));
                return;
            }

            completeCallback();
        });
    }