/// <summary> /// 发送个推信息【按用户列表进行发送】【可批量,支持IOS和安卓 批量与单个用户,通知与传透】 /// 程序可自动判定这些用户是否有推送设置,如果有才会提交推送平台进行发送 /// </summary> /// <param name="condtion"></param> /// <returns></returns> public ReplayBase SendGTuiPushByUsersList(SendGeTuiPushByUsersIdRequestModel condtion) { condtion.createdBy = User.Identity.Name; ReplayBase result = PushService.SendGTuiPushByUsersList(condtion); return(result); }
/// <summary> /// 某個留言被回覆的推播 /// </summary> /// <param name="circleKey">學習圈代碼</param> /// <param name="eventId">主題討論代碼</param> /// <param name="eventName">主題討論名稱</param> /// <param name="replyMember">回覆者資訊</param> /// <param name="beReplyMemberInfo">被回覆的人資訊</param> /// <param name="isTag">是否為回覆</param> /// <returns></returns> private async Task PushMsgReplyAsync(string circleKey, Guid eventId, string eventName, Infrastructure.Entity.Member replyMember, Infrastructure.Entity.Member beReplyMemberInfo, bool?isTag = false) { var eventMessage = isTag.Value ? (string.Format("{0}回應了一則主題討論的回覆", replyMember.Name)) : (string.Format("{0}回應了一則主題討論的留言", replyMember.Name)); var noticeMsg = isTag.Value ? string.Format("{0}回應了一則主題討論的回覆:「{1}」", replyMember.Name, eventName) : string.Format("{0}回應了一則主題討論的留言:「{1}」", replyMember.Name, eventName); discussionMsgService = new DiscussionFuncMsg(); // var pushMember =replyMember.Id!= beReplyMemberInfo.Id ? new string[1] { beReplyMemberInfo.Account } : new string[0]; var replyMembers = discussionMsgService.GetReplyMemberList(eventId, replyMember).ToList(); if (replyMembers.Count() > 0) { noticeService = new NoticeService(); //新增多筆訊息資料 noticeService.AddMultipleNotice(replyMembers, eventId, circleKey, noticeMsg); //廣播訊息資訊 SendNotice(replyMembers, circleKey); var pushService = new PushService(); if (isTag.Value) { await pushService.PushMsgAsync("ToDiscussionActivity", circleKey, eventId, "推播_查看主題討論-回覆被回覆", replyMembers.Select(t => t.Account).ToArray(), eventMessage); } else { await pushService.PushMsgAsync("ToDiscussionActivity", circleKey, eventId, "推播_查看主題討論-留言被回覆", replyMembers.Select(t => t.Account).ToArray(), eventMessage); } } }
public AlertasController(PrihoodContext context, AuthService a, PushService p, EmailService e) { db = context; auth = a; pushService = p; emailService = e; }
public async Task <JsonResult> UpdateTask(int id, TaskIn model) { var notify = false; var task = ContentService.Get <TaskItem>(model.Id); if (model.AssignedTo.HasValue && model.AssignedTo != task.AssignedTo && model.AssignedTo != User.Id) { notify = true; } task.Name = model.Name; task.Description = model.Description; task.Completed = model.Completed; task.DueDate = model.DueDate; task.AssignedTo = model.AssignedTo; task.Priority = model.Priority; var updated = ContentService.Update <TaskItem>(task); // notify if (notify) { NotificationService.Insert( new Notification(model.AssignedTo.Value, $@"{User.GetTitle()} assigned you to the task <strong>{task.Name}</strong>") { Link = task } ); } // push realtime event await PushService.Push("task_updated", task); return(Json(updated)); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.Window.RequestFeature(WindowFeatures.ActionBar); // Name of the MainActivity theme you had there before. // Or you can use global::Android.Resource.Style.ThemeHoloLight base.SetTheme(Resource.Style.MainTheme); base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); Plugin.Iconize.Iconize.Init(Resource.Id.toolbar, Resource.Id.sliding_tabs); // Could also be Resource.Id.tabs ToastService.Init(this); PermissionService.Init(this); PushService.SetContext(this); LoadApplication(new App()); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; }
public ActionResult Create(CafeStatusModels cafeStatus) { if (ModelState.IsValid) { var lastStatus = db.Status.OrderByDescending(p => p.Data).FirstOrDefault(); if (lastStatus == null || (DateTime.Now - lastStatus.Data > TimeSpan.FromMinutes(1))) { cafeStatus.Data = DateTime.Now; cafeStatus.UserName = this.User.Identity.Name; db.Status.Add(cafeStatus); db.Status.RemoveRange(db.Status.OrderByDescending(p => p.Data).Skip(10).ToList()); db.SaveChanges(); if (cafeStatus.Pronto && (lastStatus == null || lastStatus.Pronto != cafeStatus.Pronto)) { PushService.Send(); } } return(RedirectToAction("Index")); } return(View(cafeStatus)); }
public SyncService(IDomainWebsocketClient client) { // -- websockets this.websocketClient = client; this.websocketClient.OnMessage += HandleMessage; this.websocketClient.OnConnectionError += OnConnectionError; // -- push/poll this.push = new PushService(this.websocketClient); this.push.OnSendFailed += PushOnOnSendFailed; this.poll = new PollService(); // -- state machine this.stateMachine = new StateMachine <State, Trigger>(State.Idle, FiringMode.Queued); this.stateMachine.OnTransitioned(OnTransitioned); this.stateMachine.OnUnhandledTrigger((state, trigger) => { Logger.Debug($"Unhandled trigger: {trigger} [{state}]"); }); this.VersionFetcher = new HttpVersionFetcher(); InitStateMachine(); this.scheduleStopWatch.Start(); }
public async void SingleConfiguration_Options_PushFailed() { var config = new PushChannelConfiguration() { ChannelType = TestChannelType, Id = "TestId" }; var ex = new PushException("test"); var providerMock = new Mock <IPushProvider>(MockBehavior.Strict); providerMock.Setup(v => v.PushAsync(It.IsAny <string>(), It.IsAny <PushOptions>())) .Throws(ex); var pushService = new PushService(MockByConfigs(new[] { config }), new[] { MockByProvider(new Dictionary <string, IPushProvider> { { config.Id, providerMock.Object } }) }); var res = await Assert.ThrowsAsync <PushFailedException>(async() => await pushService.Push("userid", new Dictionary <string, string>(), "payload", null)); Assert.Single(res.Failures); Assert.Same(config, res.Failures[0].Configuration); Assert.Same(ex, res.Failures[0].Exception); Assert.Same(ex, res.InnerException); }
public async void MultiConfiguration_PartiallyFailed() { var config1 = new PushChannelConfiguration() { ChannelType = TestChannelType, Id = "1" }; var config2 = new PushChannelConfiguration() { ChannelType = TestChannelType, Id = "2" }; var config3 = new PushChannelConfiguration() { ChannelType = TestChannelType, Id = "3" }; var ex1 = new PushException("test"); var ex2 = new PushException("test"); var providerMock1 = new Mock <IPushProvider>(MockBehavior.Strict); providerMock1.Setup(v => v.PushAsync(It.IsAny <string>(), It.IsAny <PushOptions>())) .Throws(ex1); var providerMock2 = new Mock <IPushProvider>(MockBehavior.Strict); providerMock2.Setup(v => v.PushAsync(It.IsAny <string>(), It.IsAny <PushOptions>())) .Throws(ex2); var providerMock3 = new Mock <IPushProvider>(MockBehavior.Strict); providerMock3.Setup(v => v.PushAsync(It.IsAny <string>(), It.IsAny <PushOptions>())) .Returns(Task.CompletedTask); var pushService = new PushService(MockByConfigs(new[] { config1, config2, config3 }), new[] { MockByProvider(new Dictionary <string, IPushProvider> { { config1.Id, providerMock1.Object }, { config2.Id, providerMock2.Object }, { config3.Id, providerMock3.Object } }) }); var res = await Assert.ThrowsAsync <PushPartiallyFailedException>(async() => await pushService.Push("userid", new Dictionary <string, string>(), "payload", null)); Assert.Equal(2, res.Failures.Length); Assert.Collection(res.Failures, v => { Assert.Same(config1, v.Configuration); Assert.Same(ex1, v.Exception); }, v => { Assert.Same(config2, v.Configuration); Assert.Same(ex2, v.Exception); }); Assert.Collection(res.InnerExceptions, v => Assert.Same(ex1, v), v => Assert.Same(ex2, v)); Assert.Single(res.Succeeded); Assert.Collection(res.Succeeded, v => { Assert.Same(config3, v.Configuration); Assert.Null(v.Exception); }); }
static void Main(string[] args) { string certificatesFolder = System.Configuration.ConfigurationManager.AppSettings["certificate_path"]; string certificatesPassword = System.Configuration.ConfigurationManager.AppSettings["certificate_password"]; InitFactories(); using (var db = new NotificationsModel()) { char input; do { Product p0 = db.Products.Find(1); p0.Price = 0.49; db.SaveChanges(); PushService service = PushService.Instance; service.Init(certificatesFolder, certificatesPassword, "", "", db.Notifications); service.Push(); // Restore the normal state p0.Price = 0.99; db.SaveChanges(); input = Console.ReadKey().KeyChar; } while (input == 'c'); } }
/// <summary> /// Method used to send pushnotifications /// </summary> /// <param name="deviceID">The deviceID of the device the notification needs to be send to</param> /// <param name="message">The message that needs to be send</param> /// <returns></returns> public static bool SendPushNotification(string deviceID, string message) { bool status = true; bool sandBox = true; if (count == null) { count = 1; } else { count++; } PushService push = new PushService(); var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../PushNotification/brakelnotify.p12")); //Configure and start Apple APNS push.StartApplePushService(new ApplePushChannelSettings(!sandBox, appleCert, "brakel")); //Fluent construction of an iOS notification push.QueueNotification(NotificationFactory.Apple() .ForDeviceToken(deviceID) .WithAlert(message) .WithBadge(count)); return(status); }
private async void InitPushService() { try { if (Channel != null) { Channel.PushNotificationReceived -= OnPushNotificationReceived; Channel = null; } Channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); Channel.PushNotificationReceived += OnPushNotificationReceived; var timeout = Config.GetValue(ConfigSetting.PushServiceExpiration, 0L, false).TimeStampToDate(); if (timeout <= DateTime.Now) { PushService.InitBmob("e9c75afb85827f7eda486d8eaa5eb304", "c88dc50c5af870db43d4de302cce50d5"); PushService.InitPushService(Channel, "Push", () => { Config.SetValue(ConfigSetting.PushServiceExpiration, Channel.ExpirationTime.LocalDateTime.GetTimeStampSeconds(), false); }); } } catch (Exception ex) { } }
public void Simple() { var service = new PushService { RequestBuilder = RequestBuilderHelper.Build() }; var pushNotification = new PushNotificationRequest { DeviceTokens = new List <string> { RemoteSettings.AppleDeviceId }, Payload = new PushPayload { Alert = "Alert" }, CustomData = new Dictionary <string, string> { { "Key", "Value" } } }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(pushNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public ActionResult FindPageList() { int count; var list = PushService.FindPageList(Request.Params, out count); return(ToDataGrid(list, count)); }
public ActionResult GetPushResult(string pushId, string typeStr) { int count; var list = PushService.GetPushResult(pushId, typeStr, Request.Params, out count); return(ToDataGrid(list, count)); }
public void Simple() { var service = new PushService { RequestBuilder = ServerRequestBuilder.Instance }; var notification = new PushNotificationRequest { Tags = new List <string> { "MyTag" }, ExcludeTokens = new List <string> { "TokenToExclude" }, DeviceTokens = new List <string> { "AppleDeviceId" }, Aliases = new List <string> { "MyAlias" }, Payload = new PushPayload { Alert = "Alert 2", Badge = Badge.SetTo(2), Sound = "Sound1" } }; service.Execute(notification, response => Debug.WriteLine("Success"), ExceptionHandler.Handle); }
/// <summary> /// Method used to send pushnotifications /// </summary> /// <param name="deviceID">The deviceID of the device the notification needs to be send to</param> /// <param name="message">The message that needs to be send</param> /// <returns>Boolean indicating result status</returns> public static bool SendPushNotification(string deviceID, string message) { try { System.Diagnostics.Debug.WriteLine("Sending push message WithBadge({0}), WithAlert({1}), ForDeviceToken({2})", _count, message, deviceID); using (var push = new PushService()) { //Configure and start Apple APNS push.StartApplePushService(new ApplePushChannelSettings(!sandBox, appleCert, "brakel")); //Fluent construction of an iOS notification push.QueueNotification(NotificationFactory.Apple() .ForDeviceToken(deviceID) .WithAlert(message) .WithBadge(_count++)); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); while (ex.InnerException != null) { ex = ex.InnerException; System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } return(false); } return(true); }
public Worker() { configService = new ConfigService(); if (configService.Config.Sentry.Activate) { loggerFactory = LoggerFactory.Create(builder => { builder .AddConsole() .AddSentry(o => { o.Debug = false; o.Dsn = configService.Config.Sentry.Dsn; o.MaxBreadcrumbs = 150; o.MinimumBreadcrumbLevel = LogLevel.Information; o.MinimumEventLevel = LogLevel.Warning; }); }); } else { loggerFactory = LoggerFactory.Create(builder => { builder .AddConsole(); }); } logger = loggerFactory.CreateLogger("Push.Worker"); activityService = new ActivityService(loggerFactory); pushService = new PushService(loggerFactory); }
public ActionResult Save(Push model, List <int> type) { if (model.State == 1) { return(Content(PushService.Push(model, type).ToJson())); } return(Content(PushService.Save(model, type).ToJson())); }
private void UnsubscribeServiceEvents(PushService service) { service.Events.OnDeviceSubscriptionExpired -= Events_OnDeviceSubscriptionExpired; service.Events.OnDeviceSubscriptionIdChanged -= Events_OnDeviceSubscriptionIdChanged; service.Events.OnNotificationSendFailure -= Events_OnNotificationSendFailure; service.Events.OnNotificationSent -= Events_OnNotificationSent; service.Events.OnChannelException -= Events_OnChannelException; }
private void SubscribeServiceEvents(PushService service) { service.Events.OnDeviceSubscriptionExpired += new PushSharp.Common.ChannelEvents.DeviceSubscriptionExpired(Events_OnDeviceSubscriptionExpired); service.Events.OnDeviceSubscriptionIdChanged += new PushSharp.Common.ChannelEvents.DeviceSubscriptionIdChanged(Events_OnDeviceSubscriptionIdChanged); service.Events.OnNotificationSendFailure += new PushSharp.Common.ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure); service.Events.OnNotificationSent += new PushSharp.Common.ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent); service.Events.OnChannelException += new PushSharp.Common.ChannelEvents.ChannelExceptionDelegate(Events_OnChannelException); }
private void CleanupSession() { UnsubscribeServiceEvents(m_service); m_service = null; m_started_android = false; m_started_ios = false; m_started_w8 = false; }
public async Task <HttpStatusCodeResult> Typing(int id) { var conversation = ConversationService.Get(id); // push typing event to other conversation members await PushService.PushToUsers(PushService.EVENT_TYPING, new TypingModel { Conversation = id, User = WeavyContext.Current.User }, conversation.MemberIds.Where(x => x != WeavyContext.Current.User.Id)); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
void ConfigurePushNotifications() { // Initialize our Google Cloud Messaging Service PushService.Initialize(this); // Register device for Google Cloud Messaging PushService.Register(this); }
public IHttpActionResult StopTyping(int id) { var conversation = ConversationService.Get(id); // push typing event to other conversation members PushService.PushToUsers("typing-stopped.weavy", new { Conversation = id, User = WeavyContext.Current.User, Name = WeavyContext.Current.User.Profile.Name ?? WeavyContext.Current.User.Username }, conversation.MemberIds.Where(x => x != WeavyContext.Current.User.Id)); return(Ok(conversation)); }
public Main() { this.InitializeComponent(); HelpMethods.HideStatusBar(); PushService.CreateChannel(); this.NavigationCacheMode = NavigationCacheMode.Required; SocketInit(); }
public APNSPushConnection(PushService service, AppleConfig config) { Service = service; Config = config; _notificationIdentifier = 0; _isAvailable = false; _lockObject = new object(); }
static void Main(string[] args) { //Create our service PushService push = new PushService(); //Wire up the events push.Events.OnDeviceSubscriptionExpired += new PushSharp.Common.ChannelEvents.DeviceSubscriptionExpired(Events_OnDeviceSubscriptionExpired); push.Events.OnDeviceSubscriptionIdChanged += new PushSharp.Common.ChannelEvents.DeviceSubscriptionIdChanged(Events_OnDeviceSubscriptionIdChanged); push.Events.OnChannelException += new PushSharp.Common.ChannelEvents.ChannelExceptionDelegate(Events_OnChannelException); push.Events.OnNotificationSendFailure += new PushSharp.Common.ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure); push.Events.OnNotificationSent += new PushSharp.Common.ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent); push.Events.OnChannelCreated += new PushSharp.Common.ChannelEvents.ChannelCreatedDelegate(Events_OnChannelCreated); push.Events.OnChannelDestroyed += new PushSharp.Common.ChannelEvents.ChannelDestroyedDelegate(Events_OnChannelDestroyed); //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(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Resources/myMood-prod-push-cert.p12")); //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.StartApplePushService(new ApplePushChannelSettings(appleCert, "d1scov3r!")); //push.QueueNotification(NotificationFactory.Apple() // .ForDeviceToken("14e9c79db41cf4aa205cb72e7d60cede573cfa1867f1427ddd7372ef19c29b3a") // .WithAlert("Remember to send yourself a myMood report before handing back the iPad") // .WithSound("default") // ); using (var csv = new CsvHelper.CsvReader(new StreamReader(typeof(Device).Assembly.GetManifestResourceStream(typeof(Device).Assembly.GetName().Name + ".devices.csv")))) { while (csv.Read()) { var device = csv.GetRecord <Device>(); //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(NotificationFactory.Apple() .ForDeviceToken(device.DeviceId) .WithAlert("Remember to send yourself a myMood report before handing back the iPad!") //.WithSound("default") ); } } //Stop and wait for the queues to drains push.StopAllServices(true); Console.WriteLine("Queue Finished, press return to exit..."); Console.ReadLine(); }
public JsonResult PushWechatInfo(int pushBatchId, string openId) { var result = PushService.PushWechatInfoByBatchId(pushBatchId, new PushTemplateLog() { Target = openId }); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Detail(int id) { var model = PushService.FindById(id); ViewBag.type = ListToSelect(new Pharos.Logic.CommonDic().GetDicList(Logic.DicType.推送方式).Select(o => new SelectListItem() { Value = o.DicSN.ToString(), Text = o.Title }), "全部"); return(View(model)); }
private static void HookUpAllEvents(PushService push) { push.Events.OnDeviceSubscriptionExpired += Events_OnDeviceSubscriptionExpired; push.Events.OnDeviceSubscriptionIdChanged += new Common.ChannelEvents.DeviceSubscriptionIdChanged(Events_OnDeviceSubscriptionIdChanged); push.Events.OnChannelException += new Common.ChannelEvents.ChannelExceptionDelegate(Events_OnChannelException); push.Events.OnNotificationSendFailure += new Common.ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure); push.Events.OnNotificationSent += new Common.ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent); push.Events.OnChannelCreated += new Common.ChannelEvents.ChannelCreatedDelegate(Events_OnChannelCreated); push.Events.OnChannelDestroyed += new Common.ChannelEvents.ChannelDestroyedDelegate(Events_OnChannelDestroyed); }
public Task Unregister (string authToken, PushService service, string regid) { var url = new Uri (v8Url, "unsubscribe"); string json = GetPayload (service, regid); var httpReq = new HttpRequestMessage () { Method = HttpMethod.Post, RequestUri = url, Content = new StringContent (json, Encoding.UTF8, "application/json"), }; AddAuthToken (authToken, httpReq); return httpClient.SendAsync (httpReq); }
public async Task Register (string authToken, PushService service, string regid) { using (var httpClient = MakeHttpClient ()) { var url = new Uri (v8Url, "subscribe"); string json = GetPayload (service, regid); var httpReq = new HttpRequestMessage () { Method = HttpMethod.Post, RequestUri = url, Content = new StringContent (json, Encoding.UTF8, "application/json"), }; AddAuthToken (authToken, httpReq); await httpClient.SendAsync (httpReq).ConfigureAwait (false); } }
private string GetPayload (PushService service, string regid) { switch (service) { case PushService.GCM: return new JObject ( new JProperty ("pushservicetype", "gcm"), new JProperty ("regid", regid) ).ToString (); case PushService.APNS: return new JObject ( new JProperty ("pushservicetype", "apns"), new JProperty ("devtoken", regid) ).ToString (); default: throw new ArgumentException ("Unknown service", "service"); } }
static void Main(string[] args) { //Create our service PushService push = new PushService(); //Wire up the events push.Events.OnDeviceSubscriptionExpired += new Common.ChannelEvents.DeviceSubscriptionExpired(Events_OnDeviceSubscriptionExpired); push.Events.OnDeviceSubscriptionIdChanged += new Common.ChannelEvents.DeviceSubscriptionIdChanged(Events_OnDeviceSubscriptionIdChanged); push.Events.OnChannelException += new Common.ChannelEvents.ChannelExceptionDelegate(Events_OnChannelException); push.Events.OnNotificationSendFailure += new Common.ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure); push.Events.OnNotificationSent += new Common.ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent); push.Events.OnChannelCreated += new Common.ChannelEvents.ChannelCreatedDelegate(Events_OnChannelCreated); push.Events.OnChannelDestroyed += new Common.ChannelEvents.ChannelDestroyedDelegate(Events_OnChannelDestroyed); //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(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Resources/PushSharp.Apns.Sandbox.p12")); //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.StartApplePushService(new ApplePushChannelSettings(appleCert, "pushsharp")); //Configure and start Android GCM //IMPORTANT: The SENDER_ID is your Google API Console App Project ID. // Be sure to get the right Project ID from your Google APIs Console. It's not the named project ID that appears in the Overview, // but instead the numeric project id in the url: eg: https://code.google.com/apis/console/?pli=1#project:785671162406:overview // where 785671162406 is the project id, which is the SENDER_ID to use! push.StartGoogleCloudMessagingPushService(new GcmPushChannelSettings("785671162406", "AIzaSyC2PZNXQDVaUpZGmtsF_Vp8tHtIABVjazI", "com.pushsharp.test")); //Configure and start Windows Phone Notifications push.StartWindowsPhonePushService(new WindowsPhonePushChannelSettings()); //Configure and start Windows Notifications push.StartWindowsPushService(new WindowsPushChannelSettings("677AltusApps.PushSharpTest", "ms-app://s-1-15-2-397915024-884168245-3562497613-3307968140-4074292843-797285123-433377759", "ei5Lott1HEbbZBv2wGDTUsrCjU++Pj8Z")); //Fluent construction of a Windows Toast Notification push.QueueNotification(NotificationFactory.Windows().Toast().AsToastText01("This is a test").ForChannelUri("YOUR_CHANNEL_URI_HERE")); //Fluent construction of a Windows Phone Toast notification //IMPORTANT: For Windows Phone you MUST use your own Endpoint Uri here that gets generated within your Windows Phone app itself! push.QueueNotification(NotificationFactory.WindowsPhone().Toast() .ForEndpointUri(new Uri("http://sn1.notify.live.net/throttledthirdparty/01.00/AAFCoNoCXidwRpn5NOxvwSxPAgAAAAADAgAAAAQUZm52OkJCMjg1QTg1QkZDMkUxREQ")) .ForOSVersion(WindowsPhone.WindowsPhoneDeviceOSVersion.MangoSevenPointFive) .WithBatchingInterval(WindowsPhone.BatchingInterval.Immediate) .WithNavigatePath("/MainPage.xaml") .WithText1("PushSharp") .WithText2("This is a Toast")); //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(NotificationFactory.Apple() .ForDeviceToken("1071737321559691b28fffa1aa4c8259d970fe0fc496794ad0486552fc9ec3db") .WithAlert("1 Alert Text!") .WithSound("default") .WithBadge(7)); //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(NotificationFactory.AndroidGcm() .ForDeviceRegistrationId("APA91bG7J-cZjkURrqi58cEd5ain6hzi4i06T0zg9eM2kQAprV-fslFiq60hnBUVlnJPlPV-4K7X39aHIe55of8fJugEuYMyAZSUbmDyima5ZTC7hn4euQ0Yflj2wMeTxnyMOZPuwTLuYNiJ6EREeI9qJuJZH9Zu9g") .WithCollapseKey("NONE") .WithJson("{\"alert\":\"Alert Text!\",\"badge\":\"7\"}")); push.QueueNotification(NotificationFactory.Windows() .Toast() .ForChannelUri("https://bn1.notify.windows.com/?token=AgUAAACC2u7flXAmaevcggrLenaSdExjVfIHvr6KSZrg0KeuGrcz877rPJprPL9bEuQH%2bacmmm%2beUyXNXEM8oRNit%2bzPoigksDOq6bIFyV3XGmhUmXadysLokl5rlmTscvHGAbs%3d") .WithRequestForStatus(true) .AsToastText01("This is a test!")); //Configure and start Blackberry Push push.StartBlackberryPushService(new BlackberryPushChannelSettings( "https://cpXXXX.pushapi.eval.blackberry.com", "xxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxx")); //Fluent construction of an Blackberry Notification push.QueueNotification(NotificationFactory.Blackberry() .ForDeviceRegistrationId("xxxxxxxx") .WithData("This is a test!")); Console.WriteLine("Waiting for Queue to Finish..."); //Stop and wait for the queues to drains push.StopAllServices(true); Console.WriteLine("Queue Finished, press return to exit..."); Console.ReadLine(); }