PushSharp 3.0 Info: https://github.com/Redth/PushSharp/tree/3.0-dev#pushsharp-v30---the-push-awakens
apnsBroker.OnNotificationFailed += (notification, aggregateEx) =>
{
aggregateEx.Handle(ex =>
{
var exception = ex as ApnsNotificationException;
if (exception != null)
{
var notificationException = exception;
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;
LogManager.LogManager.Instance.Log(LogLevel.Error, exception.Message);
}
else
{
LogManager.LogManager.Instance.Log(LogLevel.Error, ex.Message);
}
return true;
});
};
apnsBroker.OnNotificationSucceeded += (notification) =>
{
LogManager.LogManager.Instance.Log(LogLevel.Error, "Notification Sent");
};
apnsBroker.Start();
foreach (var deviceToken in entity.DeviceTokens)
{
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = deviceToken,
Payload = JObject.Parse("{\"aps\":{\"badge\":1,\"sound\":\"sound.caf\",\"alert\":\"" + entity.Body + "\"}}")
});
}
apnsBroker.Stop();
}
catch (Exception e)
{
LogManager.LogManager.Instance.Log(LogLevel.Error, e.Message);
}
apnsBroker.OnNotificationFailed += (notification, aggregateEx) =>
{
aggregateEx.Handle(ex =>
{
var exception = ex as ApnsNotificationException;
if (exception != null)
{
var notificationException = exception;
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;
LogManager.LogManager.Instance.Log(LogLevel.Error, exception.Message);
}
else
{
LogManager.LogManager.Instance.Log(LogLevel.Error, ex.Message);
}
return true;
});
};
apnsBroker.OnNotificationSucceeded += (notification) =>
{
LogManager.LogManager.Instance.Log(LogLevel.Error, "Notification Sent");
};
apnsBroker.Start();
foreach (var deviceToken in entity.DeviceTokens)
{
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = deviceToken,
Payload = JObject.Parse("{\"aps\":{\"badge\":1,\"sound\":\"sound.caf\",\"alert\":\"" + entity.Body + "\"}}")
});
}
apnsBroker.Stop();
}
catch (Exception e)
{
LogManager.LogManager.Instance.Log(LogLevel.Error, e.Message);
}
}
I tried installing PushSharp using the NuGet package manager in visual studio but I keep getting the error:
Could not install package 'PushSharp 4.0.10'. You are trying to install this package into a project that targets 'Xamarin.iOS,Version=v1.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Am I doing something wrong? This is my first time trying to install packages in Xamarin so I don't really know what I'm doing
I'm getting the dreaded SSPI/badly-formatted error when I run my application from a fully-updated Windows Server 2012 R2 server, but it works fine in my development environment. I've made sure that the certificates (and private keys) are installed on the local computer, not just for the current user, and that they permissions for the private keys are shared with the appropriate users.
Here's the error message:
PushSharp.Apple.ApnsNotificationException: Apns notification error: 'ConnectionError' ---> PushSharp.Apple.ApnsConnectionException: SSL Stream Failed to Authenticate as Client ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted