示例#1
0
        public bool Send(WindowsPhoneApiNotificationPayLoad payLoad)
        {
            HookEvents(PushBroker);

            try
            {
                PushBroker.RegisterService <WindowsPhoneNotification>(new WindowsPhonePushService());

                var notification = new WindowsPhoneToastNotification()
                                   .ForEndpointUri(new Uri(payLoad.Token))
                                   .ForOSVersion(WindowsPhoneDeviceOSVersion.MangoSevenPointFive)
                                   .WithBatchingInterval(BatchingInterval.Immediate)
                                   .WithNavigatePath(payLoad.NavigationPath)
                                   .WithText1(payLoad.Message)
                                   .WithText2(payLoad.TextMessage2);

                PushBroker.QueueNotification(notification);
            }
            finally
            {
                StopBroker();
            }

            return(true);
        }
示例#2
0
        public void Test_ApplicationId_And_NotificationType_Registrations()
        {
            var b = new PushBroker();

            var gcm = new PushSharp.Android.GcmPushService(new PushSharp.Android.GcmPushChannelSettings(""));

            b.RegisterService <PushSharp.Android.GcmNotification> (gcm, "APP1");
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.GcmNotification> ("APP1").Count(), 1, "Expected 1 GcmNotification APP1 Registration");

            b.RegisterService <PushSharp.Android.GcmNotification> (gcm, "APP2");
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.GcmNotification> ("APP2").Count(), 1, "Expected 1 GcmNotification APP2 Registration");

            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.GcmNotification> ().Count(), 2, "Expected 2 GcmNotification Registrations");


            b.RegisterService <PushSharp.Android.C2dmNotification> (gcm, "APP1");
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.C2dmNotification> ("APP1").Count(), 1, "Expected 1 C2dmNotification APP1 Registration");

            b.RegisterService <PushSharp.Android.C2dmNotification> (gcm, "APP2");
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.C2dmNotification> ("APP2").Count(), 1, "Expected 1 C2dmNotification APP2 Registration");

            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.C2dmNotification> ().Count(), 2, "Expected 2 C2dmNotification Registrations");


            Assert.AreEqual(b.GetRegistrations("APP1").Count(), 2, "Expected 2 APP1 Registrations");
            Assert.AreEqual(b.GetRegistrations("APP2").Count(), 2, "Expected 2 APP2 Registrations");

            //Now remove GCM by type
            b.StopAllServices <PushSharp.Android.GcmNotification> ();
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.GcmNotification> ().Count(), 0, "Expected 0 GcmNotfication Registrations");
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.C2dmNotification> ().Count(), 2, "Expected 2 C2dmNotification Registrations");
            Assert.AreEqual(b.GetRegistrations("APP1").Count(), 1, "Expected 1 APP1 Registration");
            Assert.AreEqual(b.GetRegistrations("APP2").Count(), 1, "Expected 1 APP2 Registration");

            //Now remove APP1
            b.StopAllServices("APP1");
            Assert.AreEqual(b.GetRegistrations("APP1").Count(), 0, "Expected 0 APP1 Registration");
            Assert.AreEqual(b.GetRegistrations("APP2").Count(), 1, "Expected 1 APP2 Registration");

            //Now remove APP2
            b.StopAllServices("APP2");
            Assert.AreEqual(b.GetRegistrations("APP2").Count(), 0, "Expected 0 APP2 Registration");

            Assert.AreEqual(b.GetAllRegistrations().Count(), 0, "Expected 0 Registrations");
        }
示例#3
0
		public void Test_ApplicationId_And_NotificationType_Registrations()
		{
			var b = new PushBroker ();

			var gcm = new PushSharp.Android.GcmPushService (new PushSharp.Android.GcmPushChannelSettings (""));

			b.RegisterService<PushSharp.Android.GcmNotification> (gcm, "APP1");
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.GcmNotification> ("APP1").Count (), 1, "Expected 1 GcmNotification APP1 Registration");

			b.RegisterService<PushSharp.Android.GcmNotification> (gcm, "APP2");
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.GcmNotification> ("APP2").Count (), 1, "Expected 1 GcmNotification APP2 Registration");

			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.GcmNotification> ().Count (), 2, "Expected 2 GcmNotification Registrations");


			b.RegisterService<PushSharp.Android.C2dmNotification> (gcm, "APP1");
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.C2dmNotification> ("APP1").Count (), 1, "Expected 1 C2dmNotification APP1 Registration");

			b.RegisterService<PushSharp.Android.C2dmNotification> (gcm, "APP2");
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.C2dmNotification> ("APP2").Count (), 1, "Expected 1 C2dmNotification APP2 Registration");

			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.C2dmNotification> ().Count (), 2, "Expected 2 C2dmNotification Registrations");


			Assert.AreEqual (b.GetRegistrations ("APP1").Count (), 2, "Expected 2 APP1 Registrations");
			Assert.AreEqual (b.GetRegistrations ("APP2").Count (), 2, "Expected 2 APP2 Registrations");

			//Now remove GCM by type
			b.StopAllServices<PushSharp.Android.GcmNotification> ();
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.GcmNotification> ().Count (), 0, "Expected 0 GcmNotfication Registrations");
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.C2dmNotification> ().Count (), 2, "Expected 2 C2dmNotification Registrations");
			Assert.AreEqual (b.GetRegistrations ("APP1").Count (), 1, "Expected 1 APP1 Registration");
			Assert.AreEqual (b.GetRegistrations ("APP2").Count (), 1, "Expected 1 APP2 Registration");

			//Now remove APP1
			b.StopAllServices ("APP1");
			Assert.AreEqual (b.GetRegistrations ("APP1").Count (), 0, "Expected 0 APP1 Registration");
			Assert.AreEqual (b.GetRegistrations ("APP2").Count (), 1, "Expected 1 APP2 Registration");

			//Now remove APP2 
			b.StopAllServices ("APP2");
			Assert.AreEqual (b.GetRegistrations ("APP2").Count (), 0, "Expected 0 APP2 Registration");

			Assert.AreEqual (b.GetAllRegistrations ().Count (), 0, "Expected 0 Registrations");
		}
示例#4
0
        public void Test_NotificationType_Registrations()
        {
            var b = new PushBroker();

            var gcm = new PushSharp.Android.GcmPushService(new PushSharp.Android.GcmPushChannelSettings(""));

            b.RegisterService <PushSharp.Android.GcmNotification> (gcm);
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.GcmNotification> ().Count(), 1, "Expected 1 GcmNotification Registration");

            b.RegisterService <PushSharp.Android.C2dmNotification> (gcm);
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.C2dmNotification> ().Count(), 1, "Expected 1 C2dmNotification Registration");

            b.StopAllServices <PushSharp.Android.GcmNotification> ();
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.GcmNotification> ().Count(), 0, "Expected 0 GcmNotification Registrations");

            b.StopAllServices <PushSharp.Android.C2dmNotification> ();
            Assert.AreEqual(b.GetRegistrations <PushSharp.Android.C2dmNotification> ().Count(), 0, "Expected 0 C2dmNotification Registrations");

            Assert.AreEqual(b.GetAllRegistrations().Count(), 0, "Expected 0 Registrations");
        }
示例#5
0
		public void Test_NotificationType_Registrations()
		{
			var b = new PushBroker ();

			var gcm = new PushSharp.Android.GcmPushService (new PushSharp.Android.GcmPushChannelSettings (""));

			b.RegisterService<PushSharp.Android.GcmNotification> (gcm);
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.GcmNotification> ().Count (), 1, "Expected 1 GcmNotification Registration");

			b.RegisterService<PushSharp.Android.C2dmNotification> (gcm);
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.C2dmNotification> ().Count (), 1, "Expected 1 C2dmNotification Registration");

			b.StopAllServices<PushSharp.Android.GcmNotification> ();
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.GcmNotification> ().Count (), 0, "Expected 0 GcmNotification Registrations");

			b.StopAllServices<PushSharp.Android.C2dmNotification> ();
			Assert.AreEqual (b.GetRegistrations<PushSharp.Android.C2dmNotification> ().Count (), 0, "Expected 0 C2dmNotification Registrations");

			Assert.AreEqual (b.GetAllRegistrations ().Count (), 0, "Expected 0 Registrations");
		}
        public bool Send(GoogleGcmApiNotificationPayLoad payLoad)
        {
            HookEvents(PushBroker);

            try
            {
                PushBroker.RegisterService <GcmNotification>(new GcmPushService(new GcmPushChannelSettings(_Settings.GoogleApiAccessKey)));

                var notification = new GcmNotification()
                                   .ForDeviceRegistrationId(payLoad.Token)
                                   .WithJson(payLoad.GetGoogleFormattedJson());

                PushBroker.QueueNotification(notification);
            }
            finally
            {
                StopBroker();
            }

            return(true);
        }
示例#7
0
        public bool Send(AppleApiNotificationPayLoad payLoad)
        {
            HookEvents(PushBroker);

            try
            {
                PushBroker.RegisterService <AppleNotification>(new ApplePushService(new ApplePushChannelSettings(_Settings.CertificateContents, _Settings.CertificatePassword)));

                var notification = new AppleNotification()
                                   .ForDeviceToken(payLoad.Token)
                                   .WithAlert(payLoad.Message)
                                   .WithSound(payLoad.SoundFile)
                                   .WithBadge(payLoad.BadgeNo);

                PushBroker.QueueNotification(notification);
            }
            finally
            {
                StopBroker();
            }

            return(true);
        }
示例#8
0
 public static void RegisterAppleService(this PushBroker broker, ApplePushChannelSettings channelSettings, string applicationId, IPushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <AppleNotification>(new ApplePushService(channelSettings, serviceSettings), applicationId);
 }
示例#9
0
 public static void RegisterGcmService(this PushBroker broker, GcmPushChannelSettings channelSettings, string applicationId, IPushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <GcmNotification>(new GcmPushService(new GcmPushChannelFactory(), channelSettings, serviceSettings), applicationId);
 }