public void GCMRegistrationReady(string status)
        {
            bool statusParam;

            bool.TryParse(status, out statusParam);
            PlayFabGoogleCloudMessaging.RegistrationReady(statusParam);
        }
        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);
            });
        }
 public void GCMMessageReceived(string message)
 {
     PlayFabGoogleCloudMessaging.messageReceived(message);
 }
 public void GCMRegisterError(string error)
 {
     PlayFabGoogleCloudMessaging.registrationComplete(null, error);
 }
 public void GCMRegistered(string id)
 {
     PlayFabGoogleCloudMessaging.registrationComplete(id, null);
 }
        public void GCMRegistered(string token)
        {
            var error = (string.IsNullOrEmpty(token)) ? token : null;

            PlayFabGoogleCloudMessaging.RegistrationComplete(token, error);
        }
示例#7
0
 public static void OnGCMReady(bool status)
 {
     Debug.Log("GCM Ready!");
     PlayFabGoogleCloudMessaging.GetToken();
 }
示例#8
0
 public void OnGCMReady(bool status)
 {
     Debug.Log("AccountStatusController: GCM Ready!");
     PlayFabGoogleCloudMessaging.GetToken();
 }