Exemplo n.º 1
0
        /// <summary>
        /// Callback for handling notifications
        /// </summary>
        /// <param name="evt"></param>
        public static void UpdateNotifications(XdkNotificationPushEvent evt)
        {
            try
            {
                JsArray <JsString> myNotifications = Xdk.notification.GetNotificationList();
                int len = myNotifications.length;

                for (int i = 0; i < len; i++)
                {
                    //get the pushMobi message data
                    XdkNotificationData msgObj = Xdk.notification.GetNotificationData(myNotifications[i]);

                    //display the pushMobi message as a notification if there is no data
                    if (msgObj.richHtml.ExactEquals(undefined) && msgObj.richUrl.ExactEquals(undefined))
                    {
                        Xdk.notification.Alert(msgObj.msg, "pushMobi Message", "OK");
                        //remove the message from the server
                        Xdk.notification.DeletePushNotifications(msgObj.id);
                    }
                    else
                    {
                        Xdk.notification.ShowRichPushViewer(msgObj.id, 10, 10, 10, 10, 80, 80);
                    }
                }
            }
            catch (JsError e) { Alert("error in UpdateNotifications: " + e.message); }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Callback for handling notifications
        /// </summary>
        /// <param name="evt"></param>
        public static void UpdateNotifications(XdkNotificationPushEvent evt)
        {
            try
            {
                JsArray<JsString> myNotifications = Xdk.notification.GetNotificationList();
                int len = myNotifications.length;

                for (int i = 0; i < len; i++)
                {
                    //get the pushMobi message data
                    XdkNotificationData msgObj = Xdk.notification.GetNotificationData(myNotifications[i]);

                    //display the pushMobi message as a notification if there is no data
                    if (msgObj.richHtml.ExactEquals(undefined) && msgObj.richUrl.ExactEquals(undefined))
                    {
                        Xdk.notification.Alert(msgObj.msg, "pushMobi Message", "OK");
                        //remove the message from the server
                        Xdk.notification.DeletePushNotifications(msgObj.id);
                    }
                    else
                    {
                        Xdk.notification.ShowRichPushViewer(msgObj.id, 10, 10, 10, 10, 80, 80);
                    }
                }
            }
            catch (JsError e) { Alert("error in UpdateNotifications: " + e.message); }
        }
Exemplo n.º 3
0
        /* This callback lets you know whether the app has successfully registered to
         * recieve push notifications. This should only happen once per install (note, though, that if you
         * ask the system whether the user/app is registered for push via checkPushUser, or if you attempt
         * to reregister the app/user with the system, this even will fire again */
        public static void NotificationsRegistered(XdkNotificationPushEvent evt)
        {
            if (evt.success == false)
            {
                if (didcheckuser == false)
                {
                    Xdk.notification.CheckPushUser(chosenUsername, chosenPassword);
                    didcheckuser = true;
                }
                else
                {
                    Alert("There was an error adding push notifications " + evt.message);
                }
                return;
            }
            else
            {
                //if the app successfully registered, it's good to save the user information
                //for pulling the right the messages that belong to this user. Then you
                //can prevent unnecessarily trying to re-register the app/user
                Xdk.cache.SetCookie("pushmobi_username", chosenUsername, -1);
                Xdk.cache.SetCookie("pushmobi_password", chosenPassword, -1);
                Xdk.cache.SetCookie("pushmobi_email", chosenEmail, -1);
            }

            UpdateNotifications(evt);
        }
Exemplo n.º 4
0
        public static void RichViewerClosed(XdkNotificationPushEvent evt)
        {
            //remove the message from the server
            Xdk.notification.DeletePushNotifications(evt.id);

            // resume viewing push messages
            UpdateNotifications(evt);
        }
Exemplo n.º 5
0
        /* Callback for handling notifications */
        public static void UpdateNotifications(XdkNotificationPushEvent evt)
        {
            try
            {
                JsArray <JsString> myNotifications = Xdk.notification.GetNotificationList();
                int len = myNotifications.length;

                for (int i = 0; i < len; i++)
                {
                    //get the pushMobi message data
                    XdkNotificationData msgObj = Xdk.notification.GetNotificationData(myNotifications[i]);

                    //display the pushMobi message as a notification if there is no data
                    if (msgObj.isRich == false)
                    { //Is this a simple text push message?
                        //update the style of the t-shirt text
                        if (msgObj.data != "")
                        {
                            HtmlElement.GetById("spnShirtMessage").style.cssText = msgObj.data;
                        }
                        console.Log(HtmlElement.GetById("spnShirtMessage").style.cssText);

                        //print the message on the t-shirt
                        HtmlElement.GetById("spnShirtMessage").innerHTML = msgObj.msg;
                        Xdk.cache.SetCookie("tshirtMessage", msgObj.msg, -1);

                        //message received
                        Xdk.player.StartAudio("images/small-bell-ring-01.mp3");
                        HtmlElement.GetById("spnMessage").innerHTML = "Push Message Received";

                        //Hide the status message after 6 seconds
                        ClearTimeout(msgTimeout);
                        msgTimeout = SetTimeout("HideMessage();", 6000);

                        //remove the message from the server otherwise the app will
                        //think it has more messages waiting for it
                        Xdk.notification.DeletePushNotifications(msgObj.id);
                    }
                    else
                    {          //show rich push messages in the rich viewer
                        Xdk.notification.ShowRichPushViewer(msgObj.id, 10, 10, 10, 10, 80, 80);
                        break; // only one rich message at a time, will resume after RichViewerClosed
                    }
                }
            }
            catch (JsError e) { Alert("error in UpdateNotifications: " + e.message); }
        }
Exemplo n.º 6
0
        public static void NotificationsRegistered(XdkNotificationPushEvent evt)
        {
            if (evt.success.ExactEquals(false))
            {
                if (didcheckuser == false)
                {
                    Xdk.notification.CheckPushUser(Xdk.device.uuid, "password");
                    didcheckuser = true;
                }
                else
                {
                    Alert("There was an error adding push notifications " + evt.message);
                }
                return;
            }
            Xdk.OnNotificationPushReceive += UpdateNotifications;
            Xdk.OnNotificationPushRefresh += UpdateNotifications;

            UpdateNotifications(null);
        }
Exemplo n.º 7
0
        public static void NotificationsRegistered(XdkNotificationPushEvent evt)
        {
            if (evt.success.ExactEquals(false))
            {
                if (didcheckuser == false)
                {
                    Xdk.notification.CheckPushUser(Xdk.device.uuid, "password");
                    didcheckuser = true;
                }
                else
                {
                    Alert("There was an error adding push notifications " + evt.message);
                }
                return;
            }
            Xdk.OnNotificationPushReceive += UpdateNotifications;
            Xdk.OnNotificationPushRefresh += UpdateNotifications;

            UpdateNotifications(null);
        }
Exemplo n.º 8
0
 public static void RichViewerClosed(XdkNotificationPushEvent evt)
 {
     //remove the message from the server
     Xdk.notification.DeletePushNotifications(evt.id);
 }
Exemplo n.º 9
0
        /* Callback for handling notifications */
        public static void UpdateNotifications(XdkNotificationPushEvent evt)
        {
            try
            {
                JsArray<JsString> myNotifications = Xdk.notification.GetNotificationList();
                int len = myNotifications.length;

                for (int i = 0; i < len; i++)
                {
                    //get the pushMobi message data
                    XdkNotificationData msgObj = Xdk.notification.GetNotificationData(myNotifications[i]);

                    //display the pushMobi message as a notification if there is no data
                    if (msgObj.isRich == false)
                    { //Is this a simple text push message?

                        //update the style of the t-shirt text
                        if (msgObj.data != "")
                        {
                            HtmlElement.GetById("spnShirtMessage").style.cssText = msgObj.data;
                        }
                        console.Log(HtmlElement.GetById("spnShirtMessage").style.cssText);

                        //print the message on the t-shirt
                        HtmlElement.GetById("spnShirtMessage").innerHTML = msgObj.msg;
                        Xdk.cache.SetCookie("tshirtMessage", msgObj.msg, -1);

                        //message received
                        Xdk.player.StartAudio("images/small-bell-ring-01.mp3");
                        HtmlElement.GetById("spnMessage").innerHTML = "Push Message Received";

                        //Hide the status message after 6 seconds
                        ClearTimeout(msgTimeout);
                        msgTimeout = SetTimeout("HideMessage();", 6000);

                        //remove the message from the server otherwise the app will 
                        //think it has more messages waiting for it
                        Xdk.notification.DeletePushNotifications(msgObj.id);
                    }
                    else
                    { //show rich push messages in the rich viewer
                        Xdk.notification.ShowRichPushViewer(msgObj.id, 10, 10, 10, 10, 80, 80);
                        break; // only one rich message at a time, will resume after RichViewerClosed
                    }
                }
            }
            catch (JsError e) { Alert("error in UpdateNotifications: " + e.message); }
        }
Exemplo n.º 10
0
        /* This callback lets you know whether the app has successfully registered to 
        recieve push notifications. This should only happen once per install (note, though, that if you
        ask the system whether the user/app is registered for push via checkPushUser, or if you attempt
        to reregister the app/user with the system, this even will fire again */
        public static void NotificationsRegistered(XdkNotificationPushEvent evt)
        {
            if (evt.success == false)
            {
                if (didcheckuser == false)
                {
                    Xdk.notification.CheckPushUser(chosenUsername, chosenPassword);
                    didcheckuser = true;
                }
                else
                {
                    Alert("There was an error adding push notifications " + evt.message);
                }
                return;
            }
            else
            {
                //if the app successfully registered, it's good to save the user information
                //for pulling the right the messages that belong to this user. Then you
                //can prevent unnecessarily trying to re-register the app/user
                Xdk.cache.SetCookie("pushmobi_username", chosenUsername, -1);
                Xdk.cache.SetCookie("pushmobi_password", chosenPassword, -1);
                Xdk.cache.SetCookie("pushmobi_email", chosenEmail, -1);
            }

            UpdateNotifications(evt);
        }