TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manel Pi
NA
12
10.5k
APNS using PushSharp not working
Sep 19 2017 2:22 AM
I'm getting the following error message trying to send a push notification to my iPhone:
Apple Notification Failed: ID={12}, Code= {PushSharp.Apple.ApnsConnectionException: SSL Stream Failed to Authenticate as Client---> System.Security.Authentication.AuthenticationException: Could not make a call to SSPI; see the internal exception. ---> System.ComponentModel.Win32Exception: Message received unexpectedly, or its format is incorrect}
I'm using PushSharp library and the following code:
using
PushSharp.Apple;
using
PushSharp.Core;
using
Newtonsoft.Json.Linq;
string
p12fileName =
"C:\\webroot\\PKI\\myCertificate.p12"
;
string
p12password =
"myPassword"
;
string
deviceToken =
"myiPhoneToken"
;
var appleCert = System.IO.File.ReadAllBytes(p12fileName);
var config =
new
PushSharp.Apple.ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production, appleCert, p12password);
config.ValidateServerCertificate =
false
;
var apnsBroker =
new
ApnsServiceBroker(config);
apnsBroker.OnNotificationFailed += (notification, aggregateEx) => {
aggregateEx.Handle(ex => {
// See what kind of exception it was to further diagnose
if
(ex
is
ApnsNotificationException)
{
var notificationException = (ApnsNotificationException)ex;
// Deal with the failed notification
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;
Response.Write(
"Apple Notification Failed: ID={"
+ apnsNotification.Identifier +
"}, Code={"
+ statusCode +
"}"
);
}
else
{
// Inner exception might hold more useful information like an ApnsConnectionException
Response.Write(
"Notification Failed for some unknown reason : {"
+ ex.InnerException +
"}"
);
}
// Mark it as handled
return
true
;
});
};
apnsBroker.OnNotificationSucceeded += (notification) => {
Response.Write(
"Apple Notification Sent!"
);
};
apnsBroker.Start();
apnsBroker.QueueNotification(
new
ApnsNotification
{
DeviceToken = deviceToken,
Payload = JObject.Parse(
"{\"aps\":{\"alert\":\""
+
"Hi,, This Is a Sample Push Notification For IPhone.."
+
"\",\"badge\":1,\"sound\":\"default\"}}"
)
});
apnsBroker.Stop();
But if I try the same data at website http://pushtry.com/ I can get the push notification.
I created the certificate more than once trying to avoid any error at create certificate moment.
What I'm doing wrong? What is missing in my code?
Can anyone help me?
Kind regards in advance.
Reply
Answers (
3
)
Pass value from one object to another using objectclass
myiframe are not load data on first time click ,but again