Example #1
0
        public Task <bool> SendAsync(PushNotificationMessage message, string tag)
        {
            Ensure.That(message, nameof(message)).IsNotNull();
            Ensure.That(tag, nameof(tag)).IsNotNullOrWhiteSpace();

            return(TrySendAsync(message, tag));
        }
        public async Task <bool> Send(int athleteID, string messageText, bool shareMyEmail)
        {
            var me      = new UserProfileLogic(db).GetAthleteForUserName(this.User.Identity.Name);
            var athlete = db.Athletes.Single(i => i.AthleteID == athleteID);

            if (messageText == null)
            {
                messageText = "";
            }

            string linkToAthlete = new DeepLinkHelper().BuildLinkToAthlete(me.AthleteID);
            string linkToOpenByb = new DeepLinkHelper().BuildOpenBybLink_Athlete(me.AthleteID);

            // send an email
            string myName  = me.NameOrUserName;
            string myEmail = me.UserName;

            if (string.IsNullOrEmpty(me.RealEmail) == false)
            {
                myEmail = me.RealEmail;
            }
            string html = string.Format(htmlMessage, myName, messageText, shareMyEmail ? myEmail : "notshared", linkToAthlete, linkToOpenByb);

            await new EmailService().SendEmailToAthlete(athlete, "Snooker Byb Message", html);

            // send a push notification
            new PushNotificationsLogic(db).SendNotification(athleteID, PushNotificationMessage.BuildPrivateMessage(me, messageText));
            PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();

            return(true);
        }
        private void ChannelShellToastNotificationReceived(object sender, NotificationEventArgs e)
        {
            Debug.WriteLine("/********************************************************/");
            Debug.WriteLine("Received Toast: " + DateTime.Now.ToShortTimeString());

            foreach (string key in e.Collection.Keys)
            {
                Debug.WriteLine("{0}: {1}", key, e.Collection[key]);
                if (key == "wp:Param")
                {
                    LastPush = SDKHelpers.ParsePushData(e.Collection[key]);
                }
            }
            Debug.WriteLine("/********************************************************/");

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var message        = new PushNotificationMessage(e.Collection);
                message.Completed += (o, args) =>
                {
                    if (args.PopUpResult == PopUpResult.Ok)
                    {
                        FireAcceptedPush();
                    }
                };
                message.Show();
            });
        }
        public void WindowsPhonePushNotificationMessageNullTest()
        {
            PushNotificationMessage message = null; // it is interesting that an abstract class can be set to null. never knew this.

            var result = PushNotifier.SendPushNotificationMessage(message);

            WindowsPhonePushNotificationMessageUnitTest.AssertOperationResultValidationResultsMessageCodeOnPushNotificationSendResult(result, ResultType.Success, false, false, "0001");
        }
        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        internal MessageSendResult(PushNotificationMessage associatedMessage, Uri channelUri, WebResponse response)
        {
            Timestamp = DateTimeOffset.Now;
            AssociatedMessage = associatedMessage;
            ChannelUri = channelUri;

            InitializeStatusCodes(response as HttpWebResponse);
        }        
Example #6
0
        public Task <bool> SendAsync(PushNotificationMessage message, List <string> includeTags, List <string> excludeTags = null)
        {
            Ensure.That(message, nameof(message)).IsNotNull();
            Ensure.That(includeTags, nameof(includeTags)).IsNotNull();

            var notificationExpressionString = TagExpressionGenerator.GetExpressionString(includeTags, excludeTags);

            return(TrySendAsync(message, notificationExpressionString));
        }
Example #7
0
 private static void ValidateParameters(PushNotificationMessage message)
 {
     if (string.IsNullOrWhiteSpace(message.BodyLocalizationKey) &&
         string.IsNullOrWhiteSpace(message.TitleLocalizationKey) &&
         string.IsNullOrWhiteSpace(message.Body) &&
         string.IsNullOrWhiteSpace(message.Title))
     {
         throw new ValidationException("Push notification message is missing the content.");
     }
 }
Example #8
0
        async Task notifyAllInvolvedAthletes(int myAthleteID, NewsfeedItemTypeEnum objectType, int objectID, int commentID, string commentText)
        {
            try
            {
                var myAthlete = db.Athletes.Where(i => i.AthleteID == myAthleteID).Single();

                // list of athletes involved
                var item = this.GetNewsfeedItem(myAthleteID, objectType, objectID);
                if (item == null)
                {
                    return;
                }
                var        comments   = this.GetComments(objectType, objectID);
                List <int> athleteIDs = new List <int>();
                athleteIDs.Add(item.AthleteID);
                if (athleteIDs.Contains(item.Athlete2ID) == false)
                {
                    athleteIDs.Add(item.Athlete2ID);
                }
                foreach (var comment in comments)
                {
                    if (athleteIDs.Contains(comment.AthleteID) == false)
                    {
                        athleteIDs.Add(comment.AthleteID);
                    }
                }
                athleteIDs.Remove(0);
                athleteIDs.Remove(myAthleteID);

                foreach (int athleteID in athleteIDs)
                {
                    try
                    {
                        var athlete = db.Athletes.Where(i => i.AthleteID == athleteID).Single();

                        // send push notification
                        new PushNotificationsLogic(db).SendNotification(athleteID, PushNotificationMessage.BuildComment(myAthlete, commentText, commentID));

                        // email
                        string subject = "'Byb' - " + athlete.Name + " commented on a tracked conversation";
                        string link1   = new DeepLinkHelper().BuildOpenBybLink_Comment(commentID);
                        string link2   = new DeepLinkHelper().BuildLinkToComment(commentID);
                        string html    = string.Format(htmlMessage_Post, myAthlete.NameOrUserName, commentText, link1, link2);
                        await new EmailService().SendEmailToAthlete(athlete, subject, html);
                    }
                    catch (Exception)
                    {
                    }
                }
                PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();
            }
            catch (Exception)
            {
            }
        }
Example #9
0
        async Task notifyAllAttendees(int gameHostID, Athlete myAthlete, string commentText)
        {
            try
            {
                var gameHost = db.GameHosts.Where(i => i.GameHostID == gameHostID).Single();
                var venue    = db.Venues.Where(i => i.VenueID == gameHost.VenueID).Single();

                // list of attendees and people that commented
                var athleteIDs = gameHost.GameHostInvites.Where(i => i.IsDeniedByInvitee == false).Select(i => i.AthleteID).ToList();
                if (athleteIDs.Contains(gameHost.AthleteID) == false)
                {
                    athleteIDs.Add(gameHost.AthleteID);
                }
                var commentAthleteIDs = gameHost.Comments.Select(i => i.AthleteID).ToList();
                foreach (int id in commentAthleteIDs)
                {
                    if (athleteIDs.Contains(id) == false)
                    {
                        athleteIDs.Add(id);
                    }
                }
                athleteIDs.Remove(0);
                athleteIDs.Remove(myAthlete.AthleteID);

                foreach (int athleteID in athleteIDs)
                {
                    try
                    {
                        var athlete = db.Athletes.Where(i => i.AthleteID == athleteID).Single();

                        // send push notification
                        new PushNotificationsLogic(db).SendNotification(athleteID, PushNotificationMessage.BuildGameCommentMessage(myAthlete, commentText, gameHostID));

                        // send email
                        string when    = gameHost.When_InLocalTimeZone.ToLongDateString() + " - " + gameHost.When_InLocalTimeZone.ToShortTimeString();
                        string subject = "'Byb' - " + myAthlete.Name + " commented on an invite";
                        string link1   = new DeepLinkHelper().BuildOpenBybLink_GameHost(gameHost.GameHostID);
                        string link2   = new DeepLinkHelper().BuildLinkToGameHost(gameHost.GameHostID);
                        string html    = string.Format(htmlComment_GameHost, myAthlete.Name, gameHost.When_InLocalTimeZone, venue.Name, commentText, link1, link2);
                        await new EmailService().SendEmailToAthlete(athlete, subject, html);
                    }
                    catch (Exception)
                    {
                    }
                }

                PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();
            }
            catch (Exception)
            {
            }
        }
Example #10
0
        public static IDictionary <string, string> CreateTemplateProperties(PushNotificationMessage message)
        {
            ValidateParameters(message);

            var properties = new Dictionary <string, string>
            {
                { "sound", message.Sound },
                { "badge", message.Badge.ToString() },
                { "type", message.NotificationType.ToString() },
                { "data", message.GetData() }
            };

            PopulateContent(message, properties);

            return(properties);
        }
Example #11
0
        void processRemoteNotificationOrUrlIfNecessary(string calledFrom)
        {
            Console.WriteLine("MainActivity: processRemoteNotificationIfNecessary() {0}", calledFrom);

            if (Intent == null)
            {
                return;
            }

            // check if remote notification has been received and process it
            if (Intent.Extras != null)
            {
                string noNotificationText = "no push notification";
                string notificationText   = Intent.Extras.GetString("pushText", noNotificationText);
                string objectIDstr        = Intent.Extras.GetString("pushObjectID", "");
                int    objectID           = 0;
                int.TryParse(objectIDstr, out objectID);
                Console.WriteLine("processRemoteNotificationIfNecessary message " + notificationText);
                if (notificationText != noNotificationText)
                {
                    PushNotificationMessage message = new PushNotificationMessage()
                    {
                        Text = notificationText, ObjectID = objectID
                    };
                    Awpbs.Mobile.App.Navigator.ProcessRemoteNotification(message, true);

                    // make sure to avoid processing this if the app sleeps and then resumes
                    Intent.RemoveExtra("pushText");
                    Intent.RemoveExtra("pushObjectID");

                    return;
                }
            }

            // check if onening from a UR
            if (Intent.Data != null && Intent.Data.EncodedAuthority != null)
            {
                string url = Intent.Data.ToString();
                Console.WriteLine("Intent.Data: " + url);
                App.Navigator.ProcessOpenUrl(url);

                return;
            }
        }
        async Task emailWantsToPlay(Athlete inviteeAthlete, Athlete hostAthlete, GameHost gameHost, Venue venue)
        {
            // send an email
            string inviteeName = inviteeAthlete.NameOrUnknown;
            string inviteeEmail = inviteeAthlete.UserName;
            if (string.IsNullOrEmpty(inviteeAthlete.RealEmail) == false)
                inviteeEmail = inviteeAthlete.RealEmail;
            string when = gameHost.When_InLocalTimeZone.ToLongDateString() + " - " + gameHost.When_InLocalTimeZone.ToShortTimeString();
            string subject = "'Byb' - " + inviteeName + " wants to join your game";
            string link1 = new DeepLinkHelper().BuildOpenBybLink_GameHost(gameHost.GameHostID);
            string link2 = new DeepLinkHelper().BuildLinkToGameHost(gameHost.GameHostID);
            string html = string.Format(htmlMessage_WantsToPlay, inviteeName, when, venue.Name, gameHost.GameHostID.ToString(), link1, link2);
            await new EmailService().SendEmailToAthlete(hostAthlete, subject, html);

            // send a push notification
            new PushNotificationsLogic(db).SendNotification(hostAthlete.AthleteID,
                PushNotificationMessage.BuildGameMessage(PushNotificationMessageTypeEnum.GameWantsToBeInvited, inviteeAthlete, gameHost.GameHostID));
            PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();
        }
        async Task sendHostApproves(Athlete me, Athlete inviteeAthlete, GameHost gameHost, Venue venue)
        {
            // send an email
            string myName = me.NameOrUnknown;
            string myEmail = me.UserName;
            if (string.IsNullOrEmpty(me.RealEmail) == false)
                myEmail = me.RealEmail;
            string when = gameHost.When_InLocalTimeZone.ToLongDateString() + " - " + gameHost.When_InLocalTimeZone.ToShortTimeString();
            string subject = "'Byb' - Approved";
            string link1 = new DeepLinkHelper().BuildOpenBybLink_GameHost(gameHost.GameHostID);
            string link2 = new DeepLinkHelper().BuildLinkToGameHost(gameHost.GameHostID);
            string html = string.Format(htmlMessage_HostApproves, myName, when, venue.Name, gameHost.GameHostID.ToString(), myEmail, link1, link2);
            await new EmailService().SendEmailToAthlete(inviteeAthlete, subject, html);

            // send a push notification
            new PushNotificationsLogic(db).SendNotification(inviteeAthlete.AthleteID,
                PushNotificationMessage.BuildGameMessage(PushNotificationMessageTypeEnum.GameApprovedByHost, me, gameHost.GameHostID));
            PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();
        }
Example #14
0
        public async void ProcessRemoteNotification(PushNotificationMessage message, bool isAppStartingOrAwakening)
        {
            Console.WriteLine("Navigator.ProcessRemoteNotification - message.Text=" + message.Text);
            Console.WriteLine("Navigator.ProcessRemoteNotification - message.ObjectID=" + message.ObjectID);

            PushNotificationMessageTypeEnum?messageType = PushNotificationMessage.ParseType(message.Text);

            if (messageType == PushNotificationMessageTypeEnum.FriendRequest)
            {
                if (isAppStartingOrAwakening)
                {
                    CheckNotificationsAndOpenNotificationsPage();
                }
                else
                {
                    notificationsService.CheckForNotificationsIfNecessary();
                }
            }
            else if (messageType == PushNotificationMessageTypeEnum.PrivateMessage)
            {
                if (message.ObjectID > 0)
                {
                    await GoToPersonProfile(message.ObjectID);
                }
                await NavPage.DisplayAlert("Byb Message", message.Text, "OK");
            }
            else if (messageType == PushNotificationMessageTypeEnum.GameInvite)
            {
                if (isAppStartingOrAwakening == false)
                {
                    await NavPage.DisplayAlert("Byb Game Invite", "You were invited for a game of snooker by somebody.", "OK");
                }
                await GoToEvents();
            }
            else if (messageType == PushNotificationMessageTypeEnum.Comment && message.ObjectID > 0)
            {
                OpenNewsfeedItemPage(message.ObjectID);
            }
            else
            {
                await GoToEvents();
            }
        }
        async Task sendAnInvite(Athlete me, Athlete athlete, GameHost gameHost, Venue venue, string comments)
        {
            // send an email
            string myName = me.NameOrUnknown;
            string myEmail = me.UserName;
            if (string.IsNullOrEmpty(me.RealEmail) == false)
                myEmail = me.RealEmail;
            string when = gameHost.When_InLocalTimeZone.ToLongDateString() + " - " + gameHost.When_InLocalTimeZone.ToShortTimeString();
            string subject = "'Byb Invite' For a Game of Snooker";
            string type = (gameHost.EventType == (int)EventTypeEnum.Private ? "Private event" : "Public event") + (gameHost.LimitOnNumberOfPlayers > 0 ? (", max. " + gameHost.LimitOnNumberOfPlayers.ToString() + " can join") : "");
            string link1 = new DeepLinkHelper().BuildOpenBybLink_GameHost(gameHost.GameHostID);
            string link2 = new DeepLinkHelper().BuildLinkToGameHost(gameHost.GameHostID);
            string html = string.Format(htmlMessage_Invitation, myName, when, venue.Name, gameHost.GameHostID.ToString(), link1, link2, type, comments ?? "");
            await new EmailService().SendEmailToAthlete(athlete, subject, html);

            // send a push notification
            new PushNotificationsLogic(db).SendNotification(athlete.AthleteID, 
                PushNotificationMessage.BuildGameMessage(PushNotificationMessageTypeEnum.GameInvite, me, gameHost.GameHostID));
            PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();
        }
Example #16
0
        public int SendNotification(int athleteID, PushNotificationMessage message)
        {
            var deviceTokens = db.DeviceTokens.Where(i => i.AthleteID == athleteID).ToList();

            foreach (var deviceToken in deviceTokens)
            {
                var notification = new Awpbs.PushNotification()
                {
                    DeviceTokenID    = deviceToken.DeviceTokenID,
                    TimeCreated      = DateTime.UtcNow,
                    Status           = (int)PushNotificationStatusEnum.Prepared,
                    NotificationText = message.Text,
                    ObjectID1        = message.ObjectID,
                    IsProduction     = Config.IsProduction,
                };
                db.PushNotifications.Add(notification);
            }
            db.SaveChanges();

            return(deviceTokens.Count);
        }
Example #17
0
        private async Task <bool> TrySendAsync(PushNotificationMessage message, string tagExpression)
        {
            var notification = PlatformNotificationFactory.CreateTemplateProperties(message);

            try
            {
                var outcome = await _hub.SendTemplateNotificationAsync(notification, tagExpression);

                if (outcome == null)
                {
                    return(false);
                }

                return(!(outcome.State == NotificationOutcomeState.Abandoned ||
                         outcome.State == NotificationOutcomeState.Unknown));
            }
            catch (MessagingException ex)
            {
                throw new PushNotificationException("Error while sending push notification", ex);
            }
        }
        void processRemoteNotificationIfNecessary()
        {
            if (Intent == null)
            {
                return;                 // this shouldn't be happening
            }
            // check if remote notification has been received and process it
            string noNotificationText = "no push notification";
            string notificationText   = Intent.Extras.GetString("pushText", noNotificationText);

            if (notificationText != noNotificationText)
            {
                PushNotificationMessage message = new PushNotificationMessage()
                {
                    Text = notificationText
                };
                Awpbs.Mobile.App.Navigator.ProcessRemoteNotification(message, true);

                //this.StartActivity(typeof(Awpbs.Mobile.Droid.MainActivity));
            }
        }
Example #19
0
        private static void AddLocalizationKeyValues(PushNotificationMessage message, Dictionary <string, string> properties)
        {
            properties.Add("body_loc_key", message.BodyLocalizationKey);
            properties.Add("title_loc_key", message.TitleLocalizationKey);

            var bodyArgValues  = new List <MessageAttributeValue>();
            var titleArgValues = new List <MessageAttributeValue>();

            foreach (var prop in message.GetType().GetProperties())
            {
                var locAttributes = prop.GetCustomAttributes <LocalizationParameterAttribute>().ToList();
                if (locAttributes.Count > 0)
                {
                    var value         = prop.GetValue(message).ToString();
                    var bodyAttribute = locAttributes.LastOrDefault(x => x.Target == LocalizationTarget.Body);
                    if (bodyAttribute != null)
                    {
                        bodyArgValues.Add(new MessageAttributeValue(value, bodyAttribute.Position));
                    }

                    var titleAttribute = locAttributes.LastOrDefault(x => x.Target == LocalizationTarget.Title);
                    if (titleAttribute != null)
                    {
                        titleArgValues.Add(new MessageAttributeValue(value, titleAttribute.Position));
                    }
                }
            }

            foreach (var arg in bodyArgValues.OrderBy(x => x.Position))
            {
                properties.Add($"body_loc_arg{arg.Position}", arg.Value);
            }

            foreach (var arg in titleArgValues.OrderBy(x => x.Position))
            {
                properties.Add($"title_loc_arg{arg.Position}", arg.Value);
            }
        }
Example #20
0
        void processRemoteNotification(NSDictionary remoteNotification, bool isAppStartingOrAwakening)
        {
            //string text = remoteNotification.ToString();
            //App.Navigator.NavPage.DisplayAlert("MESSAGE!", text, "Cancel");

            try
            {
                // message text
                var    aps  = (NSDictionary)remoteNotification["aps"];
                string text = aps["alert"].ToString();

                // "object ID"
                int objectID = 0;
                var custom   = (NSObject)remoteNotification["id"];
                if (custom != null)
                {
                    string strObjectID = custom.ToString();
                    int.TryParse(strObjectID, out objectID);
                }

                //App.Navigator.NavPage.DisplayAlert("MESSAGE", "text=" + text + ", objectID=" + objectID, "Cancel");

                PushNotificationMessage message = new PushNotificationMessage()
                {
                    Text = text, ObjectID = objectID
                };
                Awpbs.Mobile.App.Navigator.ProcessRemoteNotification(message, isAppStartingOrAwakening);

                // reset the badge (this also deleted notifications)
                //UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
            }
            catch (Exception exc)
            {
                string exceptionText = TraceHelper.ExceptionToString(exc);
                App.Navigator.NavPage.DisplayAlert("MESSAGE", "EXCEPTION: " + exceptionText, "Cancel");
            }
        }
Example #21
0
        public static MessageSendResultLight SendAndHandleErrors(this PushNotificationMessage message, Uri uri)
        {
            var result = default(MessageSendResultLight);

            try
            {
                var sendResult = message.Send(uri);
                result = sendResult.NotificationStatus == NotificationStatus.Received
                    ? new MessageSendResultLight {
                    Status = MessageSendResultLight.Success
                }
                    : new MessageSendResultLight {
                    Status = MessageSendResultLight.Error, Description = "The notification was not received by the device."
                };
            }
            catch (Exception exception)
            {
                result = new MessageSendResultLight {
                    Status = MessageSendResultLight.Error, Description = exception.Message
                };
            }

            return(result);
        }
Example #22
0
        public async Task <bool> RequestFriend(int athleteID)
        {
            var me      = new UserProfileLogic(db).GetAthleteForUserName(this.User.Identity.Name);
            var athlete = db.Athletes.Single(i => i.AthleteID == athleteID);

            new FriendshipLogic(db).AddFriendship(me.AthleteID, athleteID);

            // send a push notification
            new PushNotificationsLogic(db).SendNotification(athleteID, PushNotificationMessage.BuildFriendRequest(me));
            PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();

            // send an email
            string linkToAthlete = new DeepLinkHelper().BuildLinkToAthlete(me.AthleteID);
            string linkToOpenByb = new DeepLinkHelper().BuildOpenBybLink_Athlete(me.AthleteID);
            string myName        = me.NameOrUserName;
            //string myEmail = me.UserName;
            //if (string.IsNullOrEmpty(me.RealEmail) == false)
            //    myEmail = me.RealEmail;
            string html = string.Format(htmlMessage, myName, linkToAthlete, linkToOpenByb);

            await new EmailService().SendEmailToAthlete(athlete, "Friend Request", html);

            return(true);
        }
Example #23
0
 public async Task <bool> SendToSingleAsync(string tag, PushNotificationMessage model)
 {
     return(await _pushNotificationSender.SendAsync(model, tag));
 }
 private void SendNotification(List<PushNotificationDevice> Devices, string alert)
 {
     PushNotificationMessage msg = new PushNotificationMessage
     {
         alert = alert,
         badge = 0,
         sound = "sound.caf"
     };
     foreach (var Device in Devices)
     {
         string jsonMessage = JsonConvert.SerializeObject(msg);
         switch (Device.DeviceType)
         {
             case (int)RegisterVia.Android:
             case (int)RegisterVia.AndroidFacebook:
                 //---------------------------
                 // ANDROID GCM NOTIFICATIONS
                 //---------------------------
                 //Configure and start Android GCM
                 //IMPORTANT: The API KEY comes from your Google APIs Console App,
                 //under the API Access section,
                 //  by choosing 'Create new Server key...'
                 //  You must ensure the 'Google Cloud Messaging for Android' service is
                 //enabled in your APIs Console
                 push.RegisterGcmService(new GcmPushChannelSettings(GCMKey)); // Set API Key for GCM
                 //Fluent construction of an Android GCM Notification
                 //IMPORTANT: For Android you MUST use your own RegistrationId
                 //here that gets generated within your Android app itself!
                 push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(Device.DeviceToken)    // Set Actual Device Token
                                                             .WithJson(jsonMessage));
                 break;
             case (int)RegisterVia.IPhone:
             case (int)RegisterVia.IPhoneFacebook:
                 //-------------------------
                 // APPLE NOTIFICATIONS
                 //-------------------------
                 //Configure and start Apple APNS
                 // IMPORTANT: Make sure you use the right Push certificate.  Apple allows you to
                 //generate one for connecting to Sandbox, and one for connecting to Production.  You must
                 // use the right one, to match the provisioning profile you build your
                 //   app with!
                 var appleCert = File.ReadAllBytes(HostingEnvironment.MapPath(APNSCetrtificate));
                 //IMPORTANT: If you are using a Development provisioning Profile, you must use
                 // the Sandbox push notification server
                 //  (so you would leave the first arg in the ctor of ApplePushChannelSettings as
                 // 'false')
                 //  If you are using an AdHoc or AppStore provisioning profile, you must use the
                 //Production push notification server
                 //  (so you would change the first arg in the ctor of ApplePushChannelSettings to
                 //'true')
                 push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, APNSCetrtificatePassword));
                 //Extension method
                 //Fluent construction of an iOS notification
                 //IMPORTANT: For iOS you MUST MUST MUST use your own DeviceToken here that gets
                 // generated within your iOS app itself when the Application Delegate
                 //  for registered for remote notifications is called,
                 // and the device token is passed back to you
                 push.QueueNotification(new AppleNotification()
                                             .ForDeviceToken(Device.DeviceToken)//the recipient device id
                                             .WithAlert(msg.alert)//the message
                                             .WithBadge(0)
                                             .WithSound("sound.caf")
                                             );
                 break;
         }
     }
     push.StopAllServices(waitForQueuesToFinish: true);
 }
Example #25
0
        private void buttonTestNotifications_Click(object sender, EventArgs e)
        {
            var db = new ApplicationDbContext();

            Athlete athlete = db.Athletes.Single(i => i.AthleteID == 1033);

            Awpbs.Web.PushNotificationProcessor.InitSingleInstance();
            int count = 0;

            new PushNotificationsLogic(new ApplicationDbContext()).SendNotification(1033, PushNotificationMessage.BuildPrivateMessage(athlete, "HELLO!"));
            bool pushedOk = Awpbs.Web.PushNotificationProcessor.TheProcessor.PushAllPendingNotifications();

            Awpbs.Web.PushNotificationProcessor.Destroy();

            MessageBox.Show(this, "Prepared: " + count.ToString() + ". Pushed ok=" + pushedOk);
        }
 /// <summary>
 /// Initializes a new instance of this type.
 /// </summary>
 internal MessageSendResult(PushNotificationMessage associatedMessage, Uri channelUri, Exception exception)
     : this(associatedMessage, channelUri, response: null)
 {
     Exception = exception;
 }
Example #27
0
 public async Task <bool> SendForTagAsync(PushNotificationMessage model, List <string> includedTags, List <string> excludedTags)
 {
     return(await _pushNotificationSender.SendAsync(model, includedTags, excludedTags));
 }
Example #28
0
 private static void PopulateContent(PushNotificationMessage message, Dictionary <string, string> properties)
 {
     AddNativeParameters(message, properties);
     AddLocalizationKeyValues(message, properties);
 }
Example #29
0
 private static void AddNativeParameters(PushNotificationMessage message, Dictionary <string, string> properties)
 {
     properties.Add("body", message.FormatBody());
     properties.Add("title", message.FormatTitle());
 }