Пример #1
0
 private void OnGetTitleData(GetTitleDataResult result)
 {
     _androidPushSenderId = result.Data["AndroidPushSenderId"];
     Debug.Log("PlayFab: Sender id: " + _androidPushSenderId);
     PlayFabAndroidPushPlugin.Setup(_androidPushSenderId);
     PlayFabAndroidPushPlugin.TriggerManualRegistration();
 }
 public override void SetUp(UUnitTestContext testContext)
 {
     _pushRegisterApiSuccessful = false;
     PlayFabAndroidPushPlugin.StopPlugin();
     testContext.False(PlayFabAndroidPushPlugin.IsPlayServicesAvailable(), "Play Services should not be available before setup");
     PlayFabAndroidPushPlugin.OnGcmSetupStep += OnGcmSetupStep;
     PlayFabAndroidPushPlugin.OnGcmMessage   += OnGcmMessage;
     ActiveTick = null;
     _expectedMessages.Clear();
     _expectedCustom.Clear();
 }
 /// <summary>
 /// Test normal message behavior
 /// Send any immediate notifications and verify that all formats and inputs work
 /// The immediate messages still take a moment to complete
 /// </summary>
 private void SendImmediateNotificationsAndWait()
 {
     PlayFabAndroidPushPlugin.SendNotification(new PlayFabNotificationPackage {
         Id = 0, Message = null, ScheduleDate = null, Title = null, ScheduleType = ScheduleTypes.None, CustomData = null, Icon = null, Sound = null
     });
     // Don't expect this one to arrive, but it shouldn't crash anything
     PlayFabAndroidPushPlugin.SendNotificationNow("CS-M Test Message");
     _expectedMessages.Add("CS-M Test Message");
     PlayFabAndroidPushPlugin.SendNotification(new PlayFabNotificationPackage("Obj Message", "Obj Title"));
     _expectedMessages.Add("Obj Message");
 }
        /// <summary>
        /// Send several scheduled notifications and verify that everything about them occurs on schedule
        /// </summary>
        private void SendScheduledNotificationsAndWait()
        {
            PlayFabAndroidPushPlugin.ScheduleNotification("UTC Scheduled Test Message", DateTime.UtcNow + TimeSpan.FromSeconds(MsgDelay), ScheduleTypes.ScheduledUtc);
            _expectedMessages.Add("UTC Scheduled Test Message");
            PlayFabAndroidPushPlugin.ScheduleNotification("Local Scheduled Test Message", DateTime.Now + TimeSpan.FromSeconds(MsgDelay), ScheduleTypes.ScheduledLocal);
            _expectedMessages.Add("Local Scheduled Test Message");
            var scheduledMessage = new PlayFabNotificationPackage("Scheduled Message Obj", "Scheduled Title", 0, DateTime.UtcNow + TimeSpan.FromSeconds(MsgDelay), ScheduleTypes.ScheduledUtc, "test custom");

            PlayFabAndroidPushPlugin.SendNotification(scheduledMessage);
            _expectedMessages.Add("Scheduled Message Obj");
            _expectedCustom.Add("test custom");
        }
Пример #5
0
        /// <summary>
        /// Init should be called before PlayFab Login, if you do not yet have the androidPushSenderId
        /// </summary>
        public static void Init()
        {
            if (_singletonInstance != null) // Check if we have already created this object.
            {
                return;
            }

            var playfabGo = GameObject.Find(GAME_OBJECT_NAME); // Create GameObject and place it in the scene.

            if (playfabGo == null)
            {
                playfabGo = new GameObject(GAME_OBJECT_NAME);
                DontDestroyOnLoad(playfabGo);
            }
            _singletonInstance = playfabGo.GetComponent <PlayFabAndroidPushPlugin>() ?? playfabGo.AddComponent <PlayFabAndroidPushPlugin>();
            _singletonInstance.PostStatusMessage(PushSetupStatus.GameObjectInitialized);
        }
        /// <summary>
        /// Utility for tests to pass as soon as registration is successful
        /// On the first successful registration, this will piggyback some tests that can only occur on a successful registration
        /// </summary>
        /// <param name="testContext"></param>
        protected void PassOnSuccessfulRegistration(UUnitTestContext testContext)
        {
            if (_pushRegisterApiSuccessful)
            {
                testContext.True(PlayFabAndroidPushPlugin.IsPlayServicesAvailable(), "This test should have made Play Services available");

                if (!_messagesTested)
                {
                    PlayFabAndroidPushPlugin.AlwaysShowOnNotificationBar(false); // For the purpose of this test, hide the notifications from the device notification tray
                    SendImmediateNotificationsAndWait();
                    SendScheduledNotificationsAndWait();
                    ActiveTick = WaitForExpectedMessages;
                }
                else
                {
                    testContext.EndTest(UUnitFinishState.PASSED, null);
                }
            }
        }
 public override void TearDown(UUnitTestContext testContext)
 {
     PlayFabAndroidPushPlugin.StopPlugin();
     testContext.False(PlayFabAndroidPushPlugin.IsPlayServicesAvailable(), "Play Services should not be available after shutdown");
     PlayFabClientAPI.ForgetClientCredentials();
 }
Пример #8
0
 public override void SetUp(UUnitTestContext testContext)
 {
     base.SetUp(testContext);
     PlayFabAndroidPushPlugin.Init();
 }
Пример #9
0
 private void OnLoginSuccess(LoginResult result)
 {
     PlayFabAndroidPushPlugin.TriggerManualRegistration();
 }
Пример #10
0
 public override void SetUp(UUnitTestContext testContext)
 {
     base.SetUp(testContext);
     PlayFabAndroidPushPlugin.Setup(AndroidPushSenderId);
 }