Ejemplo n.º 1
0
 private void SwitchToFacebookUserInternal()
 {
     GetSocial.Init(Identity.Facebook(AccessToken.CurrentAccessToken.TokenString),
                    () =>
     {
         _console.LogD("Successfully initialized with identity");
         SetFacebookUserDetails();
     },
                    error => _console.LogE("Initialize with identity failed:" + error)
                    );
 }
Ejemplo n.º 2
0
 void InitWithCustom()
 {
     GetSocial.Init(
         Identity.Custom(AuthSection.CustomProviderId, _identityId, _identityToken),
         () =>
     {
         _enterIdentityData = false;
         _console.LogD("Successfully logged into identity");
         FetchCurrentUserData();
     },
         error => _console.LogE(string.Format("Failed to log into identity '{0}', reason: {1}", AuthSection.CustomProviderId,
                                              error))
         );
 }
Ejemplo n.º 3
0
 void DrawMainView()
 {
     GUILayout.Label("API", GSStyles.NormalLabelText);
     if (GetSocial.IsInitialized)
     {
         Button("User Management", ShowMenuSection <AuthSection>);
     }
     else
     {
         Button("Init with anonymous", () => GetSocial.Init());
         if (_enterIdentityData)
         {
             DemoGuiUtils.DrawRow(() =>
             {
                 _identityId    = GUILayout.TextField(_identityId, GSStyles.TextField);
                 _identityToken = GUILayout.TextField(_identityToken, GSStyles.TextField);
             });
             DemoGuiUtils.DrawRow(() =>
             {
                 Button("Init", InitWithCustom);
                 Button("Cancel", () => { _enterIdentityData = false; });
             });
         }
         else
         {
             Button("Init with custom identity", () => { _enterIdentityData = true; });
         }
         Button("Init with FB", InitWithFacebook);
     }
     Button("InApp Purchase Api", ShowMenuSection <InAppPurchaseApiSection>);
     Button("Promo Codes", ShowMenuSection <PromoCodesSection>);
     Button("Custom Analytics Events", ShowMenuSection <CustomAnalyticsEventSection>);
     GUILayout.Space(30f);
     GUILayout.Label("Invites", GSStyles.NormalLabelText);
     Button("Smart Invites", ShowMenuSection <SmartInvitesApiSection>);
     Button("Set Referrer", ShowMenuSection <SetReferrerSection>);
     Button("Referred Users", ShowMenuSection <ReferredUsersSection>);
     Button("Referrer Users", ShowMenuSection <ReferrerUsersSection>);
     GUILayout.Space(30f);
     GUILayout.Label("Notification", GSStyles.NormalLabelText);
     Button("Send Notification", ShowMenuSection <SendNotificationSection>);
     Button("Notifications", ShowMenuSection <NotificationsSection>);
     GUILayout.Space(30f);
     GUILayout.Label("Communities", GSStyles.NormalLabelText);
     Button("Timeline", () => PushMenuSection <ActivitiesSection>(section => section.Query = ActivitiesQuery.Timeline()));
     Button("Find Tags", ShowMenuSection <TagsSection>);
     Button("Post to Timeline", () => PushMenuSection <PostActivitySection>(section => section.Target = PostActivityTarget.Timeline()));
     Button("My Friends", () => PushMenuSection <FriendsSection>(section => section.User = UserId.CurrentUser()));
     Button("Suggested Friends", ShowMenuSection <SuggestedFriendsSection>);
     Button("My Followers", () => PushMenuSection <FollowersSection>(section =>
     {
         section.Name  = "Me";
         section.Query = FollowersQuery.OfUser(UserId.CurrentUser());
     }));
     Button("Followed By Me", () => PushMenuSection <FollowingSection>(section =>
     {
         section.Name = "Me";
         section.User = UserId.CurrentUser();
     }));
     Button("Search Topics", ShowMenuSection <TopicsSearchSection>);
     Button("My Topics", () => PushMenuSection <FollowedTopicsSection>(section =>
     {
         section.User = UserId.CurrentUser();
     }));
     Button("Search Users", ShowMenuSection <UsersSearchSection>);
     GUILayout.Space(30f);
     GUILayout.Label("UI", GSStyles.NormalLabelText);
     Button("Activity Feed", ShowMenuSection <ActivityFeedUiSection>);
     Button("Notification Center", ShowMenuSection <NotificationUiSection>);
     Button("UI Customization", ShowMenuSection <UiCustomizationSection>);
     GUILayout.Space(30f);
     GUILayout.Label("Other", GSStyles.NormalLabelText);
     DrawSettings();
 }
Ejemplo n.º 4
0
    public void SetupGetSocial()
    {
        Notifications.SetOnTokenReceivedListener(deviceToken => {
            _console.LogD(string.Format("DeviceToken: {0}", deviceToken), false);
        });
        Notifications.SetOnNotificationReceivedListener(notification => {
            // handle chat message
            if (notification.Action.Type.Equals("open_chat_message"))
            {
                _latestChatId = notification.Action.Data["open_messages_for_id"];
                if (GetSocial.IsInitialized)
                {
                    ShowChat();
                }
            }
            if (notification.Action.Type.Equals(GetSocialActionType.AddFriend))
            {
                ShowPopup(notification);
            }
            _console.LogD(string.Format("Notification received : {0}", notification));
        });
        Notifications.SetOnNotificationClickedListener((notification, context) => {
            _console.LogD(string.Format("Notification wasClicked : {0}", notification));
            HandleAction(notification.Action);
        });

        _console.LogD("Setting up GetSocial...");
        _getSocialUnitySdkVersion            = GetSocial.UnitySdkVersion;
        _getSocialUnderlyingNativeSdkVersion = GetSocial.NativeSdkVersion;

        GetSocialFBMessengerPluginHelper.RegisterFBMessengerPlugin();
        if (GetSocial.IsInitialized)
        {
            _console.LogD("GetSocial is initialized and user is retrieved");
            _currentUser  = GetSocial.GetCurrentUser();
            _isTestDevice = GetSocial.Device.IsTestDevice;
            FetchCurrentUserData();
        }
        else
        {
            GetSocial.AddOnCurrentUserChangedListener(user => {
                _console.LogD("GetSocial is initialized and user is retrieved");
                _currentUser  = user;
                _isTestDevice = GetSocial.Device.IsTestDevice;
                FetchCurrentUserData();
            });
        }

        Invites.SetOnReferralDataReceivedListener((referralData) => {
            var logMessage = string.Empty;

            if (referralData != null)
            {
                logMessage += string.Format("Token: {0}\n", referralData.Token);
                logMessage += string.Format("Referrer user id: {0}\n", referralData.ReferrerUserId);
                logMessage += string.Format("Referrer channel: {0}\n", referralData.ReferrerChannelId);
                logMessage += string.Format("Is first match: {0}\n", referralData.IsFirstMatch);
                logMessage += string.Format("Is guarateed match: {0}\n", referralData.IsGuaranteedMatch);
                logMessage += "Referral Link params:\n" + referralData.LinkParams.ToDebugString();
            }
            _console.LogD("Referral data: \n" + logMessage);
        });

        GetSocial.Init();
    }