C#PushBroker:ChannelCreated被调用,但没有NotificationFailed或NotificationSent
我正在尝试发送苹果推送通知。而且,只有ChannelCreated事件在我的末尾被调用,而不是NotificationFailed或NotificationSent。此外,通知不会发送到特定的苹果设备。我还运行了telnet命令来解决这个问题,但没有成功C#PushBroker:ChannelCreated被调用,但没有NotificationFailed或NotificationSent,c#,push-notification,C#,Push Notification,我正在尝试发送苹果推送通知。而且,只有ChannelCreated事件在我的末尾被调用,而不是NotificationFailed或NotificationSent。此外,通知不会发送到特定的苹果设备。我还运行了telnet命令来解决这个问题,但没有成功 我正在使用内存,但我认为您可以取消注释stopAllServices。我最好的第一个猜测是检查端口是否为apple推送通知打开。我认为它们是在21世纪初的某个时候。Millie,取消注释push.StopAllServices会挂断进程,而且,
我正在使用内存,但我认为您可以取消注释
stopAllServices
。我最好的第一个猜测是检查端口是否为apple推送通知打开。我认为它们是在21世纪初的某个时候。Millie,取消注释push.StopAllServices会挂断进程,而且,它也不会给出任何异常。我不记得我在端口被阻塞时抛出异常。不过那是6-12个月前的事了。
public static void SendApplePushNotification(string DeviceToken, String PostData)
{
try
{
string AppleapiPassKey = ConfigurationManager.AppSettings["ApplePushPassword"];
//AppleapiPassKey = string.Empty;
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(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin/private_key_noenc.p12"));
//push.RegisterAppleService(new ApplePushChannelSettings(true,appleCert, AppleapiPassKey)); //Extension method
push.RegisterAppleService(new ApplePushChannelSettings(appleCert, AppleapiPassKey)); //Extension method
var message = new Message() { ChainId = 12, CreatedDate = DateTime.Now, Message1 = "hi how are you" };
push.QueueNotification(new AppleNotification()
.ForDeviceToken(DeviceToken)
.WithAlert(PostData)
.WithSound("Default")
//.WithCustomItem("content-available", message)
//.WithContentAvailable(1)
);
//push.StopAllServices(true);
}
catch (Exception ex)
{
LogError.LogErrorToFile(ex);
}
}
public static void DeviceSubscriptionChanged(object sender,
string oldSubscriptionId, string newSubscriptionId, INotification notification)
{
}
public static void NotificationSent(object sender, INotification notification)
{
}
public static void NotificationFailed(object sender,
INotification notification, Exception notificationFailureException)
{
}
public static void ChannelException
(object sender, IPushChannel channel, Exception exception)
{
}
public static void ServiceException(object sender, Exception exception)
{
}
public static void DeviceSubscriptionExpired(object sender,
string expiredDeviceSubscriptionId,
DateTime timestamp, INotification notification)
{
}
public static void ChannelDestroyed(object sender)
{
}
public static void ChannelCreated(object sender, IPushChannel pushChannel)
{
}