コード例 #1
0
        //---------------------------------------------------------------------
        // Helpers
        //---------------------------------------------------------------------

        private void OnTagClick(string tagName)
        {
            GetSocialUi.CreateGlobalActivityFeedView()
            .SetWindowTitle("#" + tagName)
            .SetFilterByTags(tagName)
            .Show();
        }
コード例 #2
0
    private Action OpenActivityDetailsFunc(bool showFeed)
    {
        return(() =>
        {
            GetSocial.GetActivities(ActivitiesQuery.PostsForGlobalFeed().WithLimit(1), (posts) =>
            {
                if (posts.Count == 0)
                {
                    _console.LogW("No activities, post something to global feed!");
                    return;
                }
#pragma warning disable 0618
                GetSocialUi.CreateActivityDetailsView(posts.First().Id)
                .SetWindowTitle("Unity Global")
                .SetViewStateCallbacks(() => _console.LogD("Activity details opened"),
                                       () => _console.LogD("Activity details closed"))
                .SetButtonActionListener(OnActivityActionClicked)
                .SetActionListener(OnAction)
                .SetShowActivityFeedView(showFeed)
                .SetUiActionListener((action, pendingAction) =>
                {
                    Debug.Log("Action invoked: " + action);
                    pendingAction();
                })
                .Show();
#pragma warning restore 0618
            }, (error) => _console.LogE("Failed to get activities, error: " + error.Message));
        });
    }
コード例 #3
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();
        });
    }
コード例 #4
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();
        });
    }
コード例 #5
0
 private void OnTagClicked(string tag)
 {
     GetSocialUi.CloseView();
     demoController.PushMenuSection <ActivitiesSection>(section =>
     {
         section.Query = ActivitiesQuery.Everywhere().WithTag(tag);
     });
 }
コード例 #6
0
    private void OnApplicationPause(bool pauseStatus)
    {
        if (!pauseStatus)
        {
            GetSocial.WhenInitialized(() => {
                if (_latestChatId != null)
                {
                    ShowChat();
                }
                else
                {
                    GetSocial.GetReferralData(
                        data => {
                        var referralToken = "";
                        var message       = "Referral data: " + data;
                        string promoCode  = null;
                        if (data == null)
                        {
                            message = "No referral data";
                        }
                        else
                        {
                            promoCode     = data.ReferralLinkParams.ContainsKey(LinkParams.KeyPromoCode) ? data.ReferralLinkParams[LinkParams.KeyPromoCode] : null;
                            referralToken = data.Token;
                        }

                        if (!referralToken.Equals(_latestReferralData))
                        {
                            // show popup only if chat is not shown
                            if (_latestChatId == null)
                            {
                                if (promoCode != null)
                                {
                                    message += "\n\nPROMO CODE: " + promoCode;
                                }
                                var popup = new MNPopup("Referral Data", message);
                                popup.AddAction("OK", () => { });
                                if (promoCode != null)
                                {
                                    popup.AddAction("Claim Promo Code", () => PromoCodesSection.ClaimPromoCode(promoCode));
                                }
                                popup.Show();
                            }
                            _console.LogD(message);
                            _latestReferralData = referralToken;
                        }
                    },
                        error => _console.LogE("Failed to get referral data: " + error.Message)
                        );
                }
            });
        }
        else
        {
            GetSocialUi.CloseView(false);
        }
    }
コード例 #7
0
    private void OpenFeedWithId()
    {
#pragma warning disable 0618
        GetSocialUi.CreateActivityFeedView(_feed)
        .SetWindowTitle(_feed + " Feed")
        .SetButtonActionListener(OnActivityActionClicked)
        .SetActionListener(OnAction)
        .Show();
#pragma warning restore 0618
    }
コード例 #8
0
 private static void SharePromoCode(string promoCode)
 {
     GetSocialUi.CreateInvitesView()
     .SetLinkParams(new LinkParams {
         { LinkParams.KeyPromoCode, promoCode }
     })
     .SetCustomInviteContent(InviteContent.CreateBuilder()
                             .WithText("Use my Promo Code to get a personal discount: " + InviteTextPlaceholders.PlaceholderPromoCode + " . " + InviteTextPlaceholders.PlaceholderAppInviteUrl)
                             .Build())
     .Show();
 }
コード例 #9
0
    private void OpenMyCustomFeed()
    {
#pragma warning disable 0618
        GetSocialUi.CreateActivityFeedView(_feed)
        .SetWindowTitle("My Custom Feed")
        .SetButtonActionListener(OnActivityActionClicked)
        .SetActionListener(OnAction)
        .SetFilterByUser(GetSocial.User.Id)
        .Show();
#pragma warning restore 0618
    }
コード例 #10
0
    public void PresentChannelInterface(InviteChannel inviteChannel, InvitePackage invitePackage,
                                        Action onComplete, Action onCancel, Action <GetSocialError> onFailure)
    {
        GetSocialDebugLogger.D(string.Format("FacebookSharePlugin.PresentChannelInterface(), inviteChannel: {0}, invite package: {1}",
                                             inviteChannel, invitePackage));

        // GetSocialUi needs to be closed while Facebook activity is opened
        // because othewise it cannot deliever the result back to the app
        GetSocialUi.CloseView(true);
        SendInvite(invitePackage.ReferralDataUrl, onComplete, onCancel, onFailure);
    }
コード例 #11
0
    private void OpenMyFriendsGlobalFeed()
    {
#pragma warning disable 0618
        GetSocialUi.CreateGlobalActivityFeedView()
        .SetWindowTitle("My Friends Feed")
        .SetButtonActionListener(OnActivityActionClicked)
        .SetActionListener(OnAction)
        .SetShowFriendsFeed(true)
        .Show();
#pragma warning restore 0618
    }
コード例 #12
0
    private void OnTagClicked(string tag)
    {
#pragma warning disable 0618
        GetSocialUi.CreateGlobalActivityFeedView()
        .SetWindowTitle("Search #" + tag)
        .SetButtonActionListener(OnActivityActionClicked)
        .SetActionListener(OnAction)
        .SetReadOnly(true)
        .SetFilterByTags(tag)
        .Show();
#pragma warning restore 0618
    }
コード例 #13
0
    private void OpenFiteredGlobalFeedAction(string title, string userId)
    {
#pragma warning disable 0618
        GetSocialUi.CreateGlobalActivityFeedView()
        .SetWindowTitle(title)
        .SetButtonActionListener(OnActivityActionClicked)
        .SetActionListener(OnAction)
        .SetFilterByUser(userId)
        .SetReadOnly(true)
        .Show();
#pragma warning restore 0618
    }
コード例 #14
0
 void ShowNativeSmartInvitesViewCustomized()
 {
     GetSocialUi.CreateInvitesView()
     .SetWindowTitle(_smartInvitesApiSection.CustomTitle)
     .SetLinkParams(_smartInvitesApiSection.LinkParams)
     .SetCustomInviteContent(_smartInvitesApiSection.CustomInviteContent)
     .SetInviteCallbacks(
         channelId => _console.LogD("Successfully sent invite for " + channelId),
         channelId => _console.LogW("Sending invite cancelled for " + channelId),
         (channelId, error) => _console.LogE(string.Format("Failed to send invite: {0} for {1}", error.Message, channelId)))
     .Show();
 }
コード例 #15
0
        //---------------------------------------------------------------------
        // Public
        //---------------------------------------------------------------------

        public void ShowActivityFeed()
        {
            if (!IsUserAuthorized())
            {
                return;
            }

            GetSocialUi.CreateGlobalActivityFeedView()
            .SetWindowTitle("News feed")
            .SetTagClickListener(OnTagClick)
            .Show();
        }
コード例 #16
0
 private void LoadUiConfiguration(string configurationPath, ScreenOrientation orientation)
 {
     if (GetSocialUi.LoadConfiguration(configurationPath))
     {
         Screen.orientation = orientation;
         Screen.orientation = ScreenOrientation.AutoRotation;
         _console.LogD(string.Format("Successfully loaded '{0}' configuration", configurationPath));
     }
     else
     {
         _console.LogE("Failed load configuration");
     }
 }
コード例 #17
0
    protected void SetDefaultConfig()
    {
        Screen.orientation = ScreenOrientation.AutoRotation;
        bool result = GetSocialUi.LoadDefaultConfiguration();

        if (result)
        {
            _console.LogD("Successfully loaded default configuration");
        }
        else
        {
            _console.LogE("Failed load default configuration");
        }
    }
コード例 #18
0
    private void OpenGlobalFeed()
    {
#pragma warning disable 0618
        GetSocialUi.CreateGlobalActivityFeedView()
        .SetWindowTitle("Unity Global")
        .SetViewStateCallbacks(() => _console.LogD("Global feed opened"), () => _console.LogD("Global feed closed"))
        .SetButtonActionListener(OnActivityActionClicked)
        .SetActionListener(OnAction)
        .SetMentionClickListener(OnMentionClicked)
        .SetAvatarClickListener(OnUserAvatarClicked)
        .SetTagClickListener(OnTagClicked)
        .SetUiActionListener(OnUiAction)
        .Show();
#pragma warning restore 0618
    }
コード例 #19
0
 public void Invite()
 {
     if (GetSocial.IsInitialized)
     {
         var linkParams = new LinkParams();
         linkParams.Add("invite", "invite_value");
         var inviteContent = InviteContent.CreateBuilder()
                             .WithMediaAttachment(MediaAttachment.Image(image))
                             .Build();
         GetSocialUi.CreateInvitesView().SetCustomInviteContent(inviteContent).SetInviteCallbacks(
             onComplete: (channelId) => { Debug.Log("Invitation was sent via " + channelId); InitScript.Instance.ShowReward(); },
             onCancel: (channelId) => Debug.Log("Invitation via " + channelId + " was cancelled"),
             onFailure: (channelId, error) => Debug.LogError("Invitation via" + channelId + "failed, error: " + error.Message)
             ).Show();
     }
 }
コード例 #20
0
 void ShowNotificationCenterView()
 {
     GetSocialUi.CreateNotificationCenterView()
     .SetNotificationClickListener((notification) =>
     {
         _console.LogD("Notification click listener invoked: " + notification.Id);
         return(demoController.HandleAction(notification.NotificationAction));
     })
     .SetActionButtonClickListener((notification, actionButton) =>
     {
         _console.LogD("Action button listener invoked: " + actionButton.Id + " - " + notification.Id);
         return(false);
     })
     .SetViewStateCallbacks(() => _console.LogD("Notifications view opened"), () => _console.LogD("Notifications view closed"))
     .Show();
 }
コード例 #21
0
 private void OnApplicationPause(bool pauseStatus)
 {
     if (!pauseStatus)
     {
         GetSocial.AddOnInitializedListener(() => {
             if (_latestChatId != null)
             {
                 ShowChat();
             }
         });
     }
     else
     {
         GetSocialUi.CloseView(false);
     }
 }
コード例 #22
0
    public void PresentChannelInterface(InviteChannel inviteChannel, InvitePackage invitePackage,
                                        Action onComplete, Action onCancel, Action <GetSocialError> onFailure)
    {
        GetSocialDebugLogger.D(string.Format("FacebookInvitePlugin.PresentChannelInterface(), inviteChannel: {0}, invite package: {1}",
                                             inviteChannel, invitePackage));

#if UNITY_ANDROID && USE_GETSOCIAL_UI
        // Get Social UI needs to be closed while Facebook activity is opened
        // because othewise it cannot deliever the result back to the app
        GetSocialUi.CloseView(true);
#endif
        Uri imageUri = null;
        if (invitePackage.ImageUrl != null)
        {
            imageUri = new Uri(invitePackage.ImageUrl);
        }
        SendInvite(invitePackage.ReferralDataUrl, imageUri, onComplete, onCancel, onFailure);
    }
コード例 #23
0
    IEnumerator ShareDelay()
    {
        yield return(new WaitForEndOfFrame());

        Texture2D captureScreenshotAsTexture = ScreenCapture.CaptureScreenshotAsTexture();

        if (GetSocial.IsInitialized)
        {
            var inviteContent = InviteContent.CreateBuilder()
                                .WithText("Try to beat me in this game [APP_INVITE_URL]") // NOTE: if you customize the text [APP_INVITE_URL] placeholder have to be used
                                .WithMediaAttachment(MediaAttachment.Image(captureScreenshotAsTexture))
                                .Build();
            bool wasShown = GetSocialUi.CreateInvitesView()
                            .SetCustomInviteContent(inviteContent)
                            .SetInviteCallbacks(
                onComplete: (channelId) => Debug.Log("Invitation was sent via " + channelId),
                onCancel: (channelId) => Debug.Log("Invitation via " + channelId + " was cancelled"),
                onFailure: (channelId, error) => Debug.LogError("Invitation via" + channelId + "failed, error: " + error.Message)
                )
                            .Show();
        }
    }
コード例 #24
0
 static void ShowNativeSmartInvitesView()
 {
     GetSocialUi.CreateInvitesView().Show();
 }