/// <summary>
        /// Sends a notification to the user's device
        /// </summary>
        /// <param name="deviceSettings">device settings</param>
        /// <param name="message">Message Information</param>
        public bool PushNotificationToDevice(vUserDeviceSetting deviceSettings, UTD.Tricorder.Common.NotificationSystem.MobileNotificationMessage message)
        {
            if (deviceSettings.PushNotificationIsActive &&
                string.IsNullOrEmpty(deviceSettings.PushNotificationToken) == false)
            {
                //MobileNotificationMessage message = new MobileNotificationMessage();
                //message.MessageBody = notificationContent;
                message.DevicePushToken = deviceSettings.PushNotificationToken;
                //message.Sound = "ring.caf";

                if (deviceSettings.MobilePushServerID == (byte)EntityEnums.MobilePushServerEnum.Google_GCM)
                {
                    MobilePushMessageNotificationSender.SendGoogleNotification(message);
                    return(true);
                }
                if (deviceSettings.MobilePushServerID == (byte)EntityEnums.MobilePushServerEnum.Apple_APNS)
                {
                    MobilePushMessageNotificationSender.SendAppleNotification(message);
                    return(true);
                }
                else
                {
                    throw new NotImplementedException();
                }

                //Other push servers are not supported yet!
            }

            return(false);
        }
Exemplo n.º 2
0
        protected void Application_Start()
        {
            //this.BeginRequest += WebApiApplication_BeginRequest;
            this.Error += Application_Error;
            PublishDatabase();

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var appSettings = FWUtils.ConfigUtils.GetAppSettings();

            //Register our customer view engine to customize all views based on tenants
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new FWViewEngine());
            //this.BeginRequest += WebApiApplication_BeginRequest;

            // overriding Api selector since it has a bug that doesn't work with underscore
            // for urls like Doctor_Patient-MyDoctors
            GlobalConfiguration.Configuration.Services.Replace(typeof(System.Web.Http.Dispatcher.IHttpControllerSelector),
                                                               new ApiControllerSelector(GlobalConfiguration.Configuration));

            i18nLib.InitAlli18nTexts();
            MobilePushMessageNotificationSender.InitGoogleCloudMessagingService();

            notificationAgent.StartAgent();
        }