HarunBahcel / apns-sharp

Automatically exported from code.google.com/p/apns-sharp
0 stars 0 forks source link

Notification Success Event Handler is called even if there is a BadDeviceToken or NotificationLength Exception #39

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Create an alert Notification greater than 256 characters
2.Send the message using Service.QueueNotification
3.

What is the expected output? What do you see instead?
The event OnNotificationTooLong should be raised only. The corresponding event 
handler will recognize failure.
However, the test indicated that the OnNotificationSuccess event is also raised 
after the OnNotificationTooLong event. 

What version of the product are you using? On what operating system?
Apns-Sharp-1.0.3.0. Windows XP

Please provide any additional information below.
It could be due to the following peiece of code in NotificationConnection.cs

try
                                    {
                                        apnsStream.Write(notification.ToBytes());
                                    }
                                    catch (BadDeviceTokenException btex)
                                    {
                                        if (this.BadDeviceToken != null)
                                            this.BadDeviceToken(this, btex);
                                    }
                                    catch (NotificationLengthException nlex)
                                    {
                                        if (this.NotificationTooLong != null)
                                            this.NotificationTooLong(this, nlex);
                                    }

                                    string txtAlert = string.Empty;

                                    if (this.NotificationSuccess != null)
                                        this.NotificationSuccess(this, notification);

                                    sent = true;

Original issue reported on code.google.com by rajes...@gmail.com on 19 Jul 2010 at 5:38

GoogleCodeExporter commented 8 years ago
I see what you mean, we'll get around to fixing this.

Original comment by jond...@gmail.com on 15 Nov 2010 at 12:08

GoogleCodeExporter commented 8 years ago
Hello, 
     The Noificatin service works fine in my local machine (deployed in IIS)but when I was put the same on windows server 2008, I got the success while sending the notification but notification did not appears on device. Any help really greatful to me.

Thanking you in advance.

Original comment by shreemah...@gmail.com on 8 Apr 2011 at 10:03

GoogleCodeExporter commented 8 years ago
Hello, what about moving the NotificationSuccess call into the try block.
This way, there will be no send in case of exception and no re-send of the 
malformed notification.

try
{
   apnsStream.Write(notification.ToBytes());
   string txtAlert = string.Empty;

   if (this.NotificationSuccess != null)
      this.NotificationSuccess(this, notification);
}
catch (BadDeviceTokenException btex)
{
   if (this.BadDeviceToken != null)
      this.BadDeviceToken(this, btex);
}
catch (NotificationLengthException nlex)
{
   if (this.NotificationTooLong != null)
      this.NotificationTooLong(this, nlex);
}

sent = true;

Original comment by sebasbo...@gmail.com on 5 May 2011 at 1:20