Пример #1
0
 void DrawMainSection()
 {
     DemoGuiUtils.DrawButton(_pnEnabled ? "Disable Push Notifications" : "Enable Push Notifications", TogglePNEnabled, style: GSStyles.Button);
     DemoGuiUtils.DrawButton("Change Language", () => _currentSection = SettingsSubSection.ChooseLanguage,
                             style: GSStyles.Button);
     DemoGuiUtils.DrawButton("Print Device Identifier", () => _console.LogD("Device ID: " + GetSocial.Device.Identifier), style: GSStyles.Button);
     DemoGuiUtils.DrawButton("Set Global Error Listener", () =>
     {
         var result = GetSocial.SetGlobalErrorListener(OnGlobalError);
         if (result)
         {
             _console.LogD("Successfully set global error listener");
         }
         else
         {
             _console.LogE("Failed to set global error listener");
         }
     },
                             style: GSStyles.Button);
     DemoGuiUtils.DrawButton("Remove Global Error Listener", () =>
     {
         var result = GetSocial.RemoveGlobalErrorListener();
         if (result)
         {
             _console.LogD("Successfully removed global error listener");
         }
         else
         {
             _console.LogE("Failed to remove global error listener");
         }
     },
                             style: GSStyles.Button);
 }
Пример #2
0
    public void SetupGetSocial()
    {
        GetSocial.SetPushNotificationTokenListener(deviceToken => {
            _console.LogD(string.Format("DeviceToken: {0}", deviceToken), false);
        });
        GetSocial.SetNotificationListener((notification, wasClicked) => {
            // handle chat message
            if (notification.NotificationAction.Type.Equals("open_chat_message"))
            {
                _latestChatId = notification.NotificationAction.Data["open_messages_for_id"];
                if (GetSocial.IsInitialized)
                {
                    ShowChat();
                }
                return(true);
            }
            if (notification.NotificationAction.Type.Equals(GetSocialActionType.AddFriend))
            {
                ShowPopup(notification);
                return(true);
            }
            _console.LogD(string.Format("Notification(wasClicked : {0}): {1}", wasClicked, notification));
            if (!wasClicked)
            {
                return(false);
            }

            return(HandleAction(notification.NotificationAction));
        });

        // Set custom listener for global errors
        GetSocial.SetGlobalErrorListener(error => {
            _console.LogE("Global error listener invoked with message: " + error.Message);
        });

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

        RegisterInvitePlugins();

        GetSocial.User.SetOnUserChangedListener(() => {
            _console.LogD("GetSocial is initialized and user is retrieved");
            GetSocial.User.IsPushNotificationsEnabled(isEnabled => ((SettingsSection)_menuSections.Find(section => section is SettingsSection)).PnEnabled = isEnabled, error => Debug.LogError("Failed to get PN status " + error));
            FetchCurrentUserData();
        });
    }