RegisterAsync() public method

Register an Installation with particular registrationId
public RegisterAsync ( string registrationId ) : System.Threading.Tasks.Task
registrationId string The registrationId to register
return System.Threading.Tasks.Task
Beispiel #1
0
        public async void Register(Microsoft.WindowsAzure.MobileServices.Push push, IEnumerable <string> tags)
        {
            try
            {
                const string templateBodyGCM = "{\"" + HEADER_PUSH + "\":{" +
                                               "\"" + MESSAGE_PUSH + "\":\"$(messageParam)\"" +
                                               "\"" + MESSAGE_PUSH_TITLE + "\":\"$(titleParam)\"" +
                                               "\"" + IMAGE_PUSH + "\":\"$(imageParam)\"" +
                                               "}}";

                JObject templates = new JObject();
                templates["genericMessage"] = new JObject
                {
                    { "body", templateBodyGCM }
                };

                await push.RegisterAsync(RegistrationID, templates);

                Log.Info("Push Installation Id", push.InstallationId.ToString());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                // Debugger.Break();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 進行Azure 推播中樞註冊
        /// </summary>
        /// <param name="push"></param>
        /// <param name="tags"></param>
        public async void Register(Microsoft.WindowsAzure.MobileServices.Push push, IEnumerable <string> tags)
        {
            #region 進行Azure 推播中樞註冊
            try
            {
                // 設定要接收來自於 Azure 推播中樞的推播訊息格式
                string templateBodyGCM = "{\"data\":{\"message\":\"$(messageParam)\", \"title\":\"$(titleParam)\", \"args\":\"$(argsParam)\"}}";;

                JObject templates = new JObject();
                templates["genericMessage"] = new JObject
                {
                    { "body", templateBodyGCM }
                };

                // 註冊要接收的推播訊息格式
                await push.RegisterAsync(RegistrationID, templates);

                Log.Info("Push Installation Id", push.InstallationId.ToString());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                //Debugger.Break();
            }
            #endregion
        }
Beispiel #3
0
        //Registrar no Azure o App.

        public async void Register(Microsoft.WindowsAzure.MobileServices.Push push, IEnumerable <string> tags)
        {
            try
            {
                //Cada rede tem um template específico de mensagem, o messageParam é o que vale
                //este template é cadastrado no Azure (dentro do TestSend pegamos ele)
                const string templateBodyGCM = "{\"data\":{\"message\":\"$(messageParam)\"}}";

                JObject templates = new JObject();

                templates["genericMessage"] = new JObject
                {
                    { "body", templateBodyGCM }
                };


                //RegistrationID é o id do celular
                await push.RegisterAsync(RegistrationID, templates);

                Log.Info("Push Installation Id", push.InstallationId.ToString());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                Debugger.Break();
            }
        }
Beispiel #4
0
 public async void Register(Microsoft.WindowsAzure.MobileServices.Push push, IEnumerable <string> tags)
 {
     try
     {
         await push.RegisterAsync(RegistrationID);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         Debugger.Break();
     }
 }
Beispiel #5
0
        //Part: 7 Push Notification
        public async void Register(Microsoft.WindowsAzure.MobileServices.Push push, IEnumerable <string> tags)
        {
            try
            {
                //messageParam: is defined in edit favorite script from azure
                const string templateBodyGCM = "{\"data\":{\"message\":\"$(messageParam)\"}}";

                JObject templates = new JObject();
                templates["genericMessage"] = new JObject
                {
                    { "body", templateBodyGCM }
                };

                await push.RegisterAsync(RegistrationID, templates);
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #6
0
        public async void Register(Microsoft.WindowsAzure.MobileServices.Push push, IEnumerable <string> tags)
        {
            try
            {
                const string templateBodyGCM = "\"data\":{\"message\":\"$(messageParam)\"}}";
                JObject      templates       = new JObject();
                templates["genericMessage"] = new JObject
                {
                    { "body", templateBodyGCM }
                };
                await push.RegisterAsync(RegistrationId, templates);

                Log.Info("Push installation ID", push.InstallationId.ToString());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                Debugger.Break();
            }
        }