Export to GitHub

apns-sharp - issue #39

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


Posted on Jul 19, 2010 by Happy Bird

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;

Comment #1

Posted on Nov 15, 2010 by Happy Lion

I see what you mean, we'll get around to fixing this.

Comment #2

Posted on Apr 8, 2011 by Massive Bird

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.

Comment #3

Posted on May 5, 2011 by Massive Monkey

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;

Status: Accepted

Labels:
Type-Defect Priority-Medium