示例#1
0
        /// <summary>
        /// Register a particular deviceId with a template
        /// </summary>
        /// <param name="deviceId">The deviceId to register</param>
        /// <param name="jsonTemplate">The string defining the json template</param>
        /// <param name="templateName">The template name</param>
        /// <param name="tags">The tags to register to receive notifications from</param>
        /// <returns>Task that completes when registration is complete</returns>
        public Task RegisterTemplateAsync(string deviceId, string jsonTemplate, string templateName, IEnumerable <string> tags)
        {
            if (string.IsNullOrWhiteSpace(deviceId))
            {
                throw new ArgumentNullException("deviceId");
            }

            if (string.IsNullOrWhiteSpace(jsonTemplate))
            {
                throw new ArgumentNullException("jsonTemplate");
            }

            if (string.IsNullOrWhiteSpace(templateName))
            {
                throw new ArgumentNullException("templateName");
            }

            var registration = new GcmTemplateRegistration(deviceId, jsonTemplate, templateName, tags);

            return(this.RegistrationManager.RegisterAsync(registration));
        }
        /// <summary>
        /// Register a particular deviceId with a template
        /// </summary>
        /// <param name="deviceId">The deviceId to register</param>
        /// <param name="jsonTemplate">The string defining the json template</param>
        /// <param name="templateName">The template name</param>
        /// <param name="tags">The tags to register to receive notifications from</param>
        /// <returns>Task that completes when registration is complete</returns>
        public Task RegisterTemplateAsync(string deviceId, string jsonTemplate, string templateName, IEnumerable<string> tags)
        {
            if (string.IsNullOrWhiteSpace(deviceId))
            {
                throw new ArgumentNullException("deviceId");
            }

            if (string.IsNullOrWhiteSpace(jsonTemplate))
            {
                throw new ArgumentNullException("jsonTemplate");
            }

            if (string.IsNullOrWhiteSpace(templateName))
            {
                throw new ArgumentNullException("templateName");
            }

            var registration = new GcmTemplateRegistration(deviceId, jsonTemplate, templateName, tags);
            return this.RegistrationManager.RegisterAsync(registration);
        }