Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to send the push notification to ios using Push Sharp Library 2.2.2.1

I am not getting any error
but message is not displaying the apple device.

Help Appreatiated.

What I have tried:

protected void Button1_Click(object sender, EventArgs e)
       {

           var push = new PushBroker();
           push.OnNotificationSent += NotificationSent;
           push.OnChannelException += ChannelException;
           push.OnServiceException += ServiceException;
           push.OnNotificationFailed += NotificationFailed;
           push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
           push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
           push.OnChannelCreated += ChannelCreated;
           push.OnChannelDestroyed += ChannelDestroyed;

           var appleCert = File.ReadAllBytes(Server.MapPath("~/App_Data/Certificates.p12"));
           push.RegisterAppleService(new ApplePushChannelSettings(appleCert, "Sudesi@123"));
           push.QueueNotification(new AppleNotification()
                                      .ForDeviceToken("d66d339f6d974ed7de4fab006388cce75898c63cebe9fe3f0e2f34ba6a23a1b9")
                                      .WithAlert("Hello World!")
                                      .WithBadge(7));

           push.StopAllServices();

       }

       static void DeviceSubscriptionChanged(object sender,
   string oldSubscriptionId, string newSubscriptionId, INotification notification)
       {
           Console.WriteLine(notification);
       }

       //this even raised when a notification is successfully sent
       static void NotificationSent(object sender, INotification notification)
       {
           Console.WriteLine(notification);
       }

       //this is raised when a notification is failed due to some reason
       static void NotificationFailed(object sender,
       INotification notification, Exception notificationFailureException)
       {
           Console.WriteLine(notificationFailureException);
       }

       //this is fired when there is exception is raised by the channel
       static void ChannelException
           (object sender, IPushChannel channel, Exception exception)
       {
           Console.WriteLine(exception);
       }

       //this is fired when there is exception is raised by the service
       static void ServiceException(object sender, Exception exception)
       {
           Console.WriteLine(exception);
       }
       //this is raised when the particular device subscription is expired
       static void DeviceSubscriptionExpired(object sender,
       string expiredDeviceSubscriptionId,
           DateTime timestamp, INotification notification)
       {
           Console.WriteLine(notification);
       }

       //this is raised when the channel is destroyed
       static void ChannelDestroyed(object sender)
       {
           Console.WriteLine(sender);
       }

       //this is raised when the channel is created
       static void ChannelCreated(object sender, IPushChannel pushChannel)
       {
           Console.WriteLine(pushChannel);
       }
Posted
Updated 5-Mar-17 12:51pm

1 solution

That version appears quite old now - have you tried the latest release ?

Quote:
PushSharp v3.0+ is a complete rewrite of the original library, aimed at taking advantage of things like async/await, HttpClient, and generally a better infrastructure using lessons learned from the old code.


The author (did) say he was contactable for bugs (but Im guessing he'd prefer to support the new version) here PushSharp 3.0 – The Push Awakens! – Redth[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900