/// <summary>
    /// Called on a successful login attempt
    /// </summary>
    /// <param name="result">Result object returned from PlayFab server</param>
    private static void OnLoginResult(PlayFab.ClientModels.LoginResult result) //LoginResult
    {
        PF_PlayerData.PlayerId = result.PlayFabId;

#if UNITY_ANDROID && !UNITY_EDITOR
        PlayFabGoogleCloudMessaging._RegistrationReadyCallback += AccountStatusController.OnGCMReady;
        PlayFabGoogleCloudMessaging._RegistrationCallback      += AccountStatusController.OnGCMRegistration;
        PlayFabAndroidPlugin.Init(PF_GameData.AndroidPushSenderId);
#endif

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.isEditor)
        {
            if (FB.IsInitialized == false)
            {
                //FB.Init(OnInitComplete, OnHideUnity);
                FB.Init();
            }

            if (PF_Authentication.usedManualFacebook == true)
            {
                LinkDeviceId();
                PF_Authentication.usedManualFacebook = false;
            }
        }

        Debug.Log("Session Ticket: " + result.SessionTicket);

        PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none);
        if (OnLoginSuccess != null)
        {
            OnLoginSuccess(string.Format("SUCCESS: {0}", result.SessionTicket), MessageDisplayStyle.error);
        }
    }
Beispiel #2
0
 private void CheckPushStatus()
 {
     registerPush.interactable = !string.IsNullOrEmpty(PF_GameData.AndroidPushSenderId) && !string.IsNullOrEmpty(pushToken);
     if (!string.IsNullOrEmpty(PF_GameData.AndroidPushSenderId))
     {
         PlayFabAndroidPlugin.Init(PF_GameData.AndroidPushSenderId);
     }
 }
        private IEnumerator Start()
        {
            PlayFabGoogleCloudMessaging._RegistrationCallback += (token, error) => { this.deviceToken = token; };

            PlayFabGoogleCloudMessaging._MessageCallback += (message) => { this.pushHandler.ReceivedPushNotification(message); };

            PlayFabGoogleCloudMessaging._RegistrationReadyCallback += (status) =>
            {
                if (status)
                {
                    PlayFabGoogleCloudMessaging.GetToken();     // request device token
                    PlayFabAndroidPlugin.UpdateRouting(false);  // suppress push notifications while app is running
                }
            };

            // TODO [bgish]:  This should probably be located in AppSettings, if not defined print error and early out GameObject.Destroy(this);
            PlayFabAndroidPlugin.Init("GoogleAppId");

            int retryCount = 0;

            while (this.deviceToken == null)
            {
                retryCount++;

                if (retryCount >= RetryCountMax)
                {
                    break;
                }

                yield return(new WaitForSeconds(RetryWaitTime));
            }

            // if we got here and still no deviceToken, then we timed out
            if (this.deviceToken == null)
            {
                Debug.LogError("PlayFabAndroidPushHandler timed out waiting for the RegistrationCallback to complete.");

                // cleaning up this Android push notification handler so it doesn't take up any cycles
                GameObject.Destroy(this);
                yield break;
            }

            PlayFabClientAPI.AndroidDevicePushNotificationRegistration(
                new AndroidDevicePushNotificationRegistrationRequest {
                DeviceToken = this.deviceToken
            },
                (result) =>
            {
                Debug.Log("Push Notification Registration Successful!");
            },
                (error) =>
            {
                Debug.Log("Error Registering for Android Push Notifications!");
                Debug.Log(error.Error);
                Debug.Log(error.ErrorMessage);
                Debug.Log(error.ErrorDetails);
            });
        }
 private void OnApplicationFocus(bool focus)
 {
     // checking that we actually got a device token before updating routing
     if (string.IsNullOrEmpty(this.deviceToken) == false)
     {
         // if we lose focus, then we don't want to consume push notifications anymore
         PlayFabAndroidPlugin.UpdateRouting(!focus);
     }
 }
 public void ScheduleLocalPushNotification(string title, string message, DateTime dateTime)
 {
     PlayFabAndroidPlugin.ScheduleNotification(message, dateTime);
 }