Exemple #1
0
        public static void SendNotification(PlayFabNotificationPackage package)
        {
            var javaPackage = _notificationSender.CallStatic <AndroidJavaObject>("createNotificationPackage", _objActivity, package.Message, package.Id);

            package.ToJava(ref javaPackage);
            _notificationSender.CallStatic("send", _objActivity, javaPackage);
        }
        /// <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");
        }
Exemple #3
0
        private void GCMMessageReceived(string json)
        {
            Debug.Log("PlayFabGCM: Unity GCMMessageReceived, json: " + json);
            var pkg = _notificationPkgClass.CallStatic <AndroidJavaObject>("fromJson", json);

            Debug.Log("PlayFabGCM: Unity GCMMessageReceived, pkg: " + pkg.Get <string>("Message"));
            var message = PlayFabNotificationPackage.FromJava(pkg);

            Debug.Log("PlayFabGCM: Unity GCMMessageReceived, msg: " + message.Message);
            if (OnGcmMessage != null)
            {
                OnGcmMessage(message);
            }
            PostStatusMessage(PushSetupStatus.ReceivedMessage);
        }
Exemple #4
0
        public static PlayFabNotificationPackage FromJava(AndroidJavaObject package)
        {
            var output = new PlayFabNotificationPackage
            {
                Id           = package.Get <int>("Id"),
                ScheduleType = (ScheduleTypes)Enum.Parse(typeof(ScheduleTypes), package.Get <string>("ScheduleType")),
                Title        = package.Get <string>("Title"),
                Message      = package.Get <string>("Message"),
                Icon         = package.Get <string>("Icon"),
                Sound        = package.Get <string>("Sound"),
                CustomData   = package.Get <string>("CustomData"),
                ScheduleDate = null // Assigned below
            };

            DateTime temp;

            if (DateTime.TryParseExact(package.Get <string>("ScheduleDate"), SUPPORTED_PLUGIN_TIMESTAMP_FORMATS, CultureInfo.CurrentCulture, DateTimeStyles.RoundtripKind, out temp))
            {
                output.ScheduleDate = temp;
            }

            return(output);
        }
 private void OnGcmMessage(PlayFabNotificationPackage package)
 {
     Debug.Log("PlayFabGCM: Unity message package received: " + package.Message);
     _expectedMessages.Remove(package.Message);
     _expectedCustom.Remove(package.CustomData);
 }