我们已经实施了PushSharp,用于向我们的企业iOS设备发送推送通知.这是从Windows机器发送的,我们定制了从控制台应用程序调用的PushSharp代码,该应用程序计划每分钟运行一次(检查SQL Server数据库是否发送推送通知,然后发送返回的内容).这一切都很好,但我一直无法找到如何使用此库调用反馈服务的示例.我看到有一个FeedbackService.cs类,它看起来处理与Apple的反馈服务的连接,但文档没有说明它是如何工作的或如何使用它.
有没有人有一个很好的教程或如何使用反馈服务的例子?
我有使用PushSharp的Android和Apple推送通知,但我在使用Apple通知发送自定义数据时遇到问题.
这完美地发送:
push.QueueNotification(new AppleNotification()
.ForDeviceToken(device.Identifier)
.WithAlert(message)
.WithSound("default")
.WithBadge(7));
Run Code Online (Sandbox Code Playgroud)
这根本不起作用:
push.QueueNotification(new AppleNotification()
.ForDeviceToken(device.Identifier)
.WithAlert(message)
.WithSound("default")
.WithCustomItem("incidentId", new[] { 1 })
.WithBadge(7));
Run Code Online (Sandbox Code Playgroud)
后者永远不会遇到NotificationSent,NotificationFailed,ServiceException等,并且永远不会进入手机.
使用PushSharp版本2.0.4.0
我是否在尝试添加自定义数据时出错?
我正在构建一个由移动应用程序调用的 WCF REST Web 服务,以将 Apple 设备令牌插入到数据库中。我想在插入数据库之前验证设备令牌。无论如何要验证设备令牌以知道它是否有效?
我在论坛上搜索过,但找不到任何示例代码(在 .NET 中)来执行此操作,有人建议我应该使用 Apple FeedBack 服务,但我该如何在 .NET 中执行此操作?
任何人都可以向我提供一段示例代码来验证 .NET 中的 Apple 设备令牌。
非常感谢,
wcf feedback push-notification apple-push-notifications pushsharp
这更像是一般的Asp.Net/.Net生命周期问题.
我正在寻找在Asp.Net Web服务中使用PushSharp来使用APNS发送通知.
鉴于PushSharp的性质使用队列异步发送消息然后事件回调通知'OnNotificationSent'/'OnServiceException'等.这将如何在Asp.net中工作?
谢谢你的帮助.
使用Pushsharp v4.0.10(nuget软件包),GCM Authorization Failed在向Android设备发送推送通知时出现错误。
似乎在问题574(https://github.com/Redth/PushSharp/issues/574)中引发的错误已编译到nuget包中,但我仍然遇到此错误。
这可能与Firebase Cloud Messaging的引入有关吗?
有人在使用GCM方面仍然成功吗?
PushSharp仅在调用stop时处理队列.有没有人知道push sharp会处理队列或刷新队列的频率?每次我想发送通知以节省资源时,我都不想打电话停止和启动.
pushService = new PushService();
pushService.StartApplePushService(new ApplePushChannelSettings(prod, cert.InputStream.ReadToEnd(), passConfig.Value));
pushService.QueueNotification(
NotificationFactory.Apple().ForDeviceToken("mydeviceid").WithAlert("Notifications Started!").WithSound("default").WithBadge(7));
pushService.StopAllServices(true);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用PushSharp向各种设备发送通知.我的服务器端应用程序将通知发送到MSSQL中的表,以便另一个应用程序(Bot)处理这些通知并将它们发送到Apple服务器.
我使用以下代码:
static DataEntities Entities;
static void Main(string[] args)
{
Entities = new DataEntities();
var appleCert = File.ReadAllBytes(Path.GetFullPath("My_Push_Notifications.p12"));
PushBroker broker = new PushBroker();
broker.RegisterAppleService(new PushSharp.Apple.ApplePushChannelSettings(false, appleCert, "XXXXX"));
broker.OnChannelCreated += broker_OnChannelCreated;
broker.OnChannelDestroyed += broker_OnChannelDestroyed;
broker.OnChannelException += broker_OnChannelException;
broker.OnNotificationRequeue += broker_OnNotificationRequeue;
broker.OnServiceException += broker_OnServiceException;
broker.OnNotificationSent += broker_OnNotificationSent;
broker.OnNotificationFailed += broker_OnNotificationFailed;
while (true)
{
var pendingNotifications = Entities.Notifications.Include("UserDevice").Where(n => n.Status == (byte)Constants.Notifications.Status.Pending);
if (pendingNotifications.ToList().Count > 0)
{
Console.WriteLine("Pending notifications: {0}", pendingNotifications.Count());
}
else
Console.WriteLine("No pending notifications");
foreach (var notification in pendingNotifications)
{
broker.QueueNotification<AppleNotification>(new …Run Code Online (Sandbox Code Playgroud) Web应用程序充当处理来自iPhone的请求的后端.要在处理请求时从Web应用程序向iPhone发送消息(例如,用于付款),我想在服务器上发生有趣事情时向iPhone发送消息,或者如果一切都成功,则向他们发送交易详细信息.使用PushSharp或SignalR哪一个更好?它们是否都服务于同一目的?无论哪种方式,在这个主题上启发我.它让我很困惑.
生成证书后,我只导出了Keychain访问中的私钥(没有证书),导出为.p12并使用了该文件,但没有工作.我只导出了证书并导出为.p12并使用了该文件,但它也没有用.
例外是:
您已选择生产服务器,但您的证书似乎不是生产证书!请检查以确保您拥有正确的证书!
如果我使用与MoonAPNS库相同的.p12,它可以正常工作,但不能与PUSHSHarp库一起使用.我只使用push sharp进行静音通知.
我按照 PushSharp 存储库中的示例进行操作: PushSharp Android Client Sample
如果应用程序处于打开状态或在后台(通过点击主页或后退按钮),一切都运行良好。但是,如果我通过在应用程序管理器中将其滑动来关闭应用程序,我将不再收到通知。
我的假设是,由于 PushHandlerService 被标记为 [Service],即使应用程序关闭它也会保持打开状态并继续侦听通知。有没有办法在应用程序关闭的情况下继续接收通知,还是我做错了?
我会包含代码,但我所获得的内容几乎完全来自上述链接中的示例。
编辑:
我尝试在应用程序启动时触发 PushClient.Register,即使设备已经注册,希望如果它没有启动,这将启动 PushHandlerService。即使在每次启动应用程序时重新注册,当应用程序关闭时我仍然没有收到通知。
我已经实现了一个每3分钟运行一次的Windows服务,并轮询数据库以获取准备发送的通知.我将它们收集到一个列表中,确定它是ios还是android通知,然后调用PushBroker(PushSharp解决方案作为我的解决方案项目中的编译解决方案包含在内)然后迭代列表中的项目进行如下处理:
static void ProcessIOS(List<Client> IOS)
{
PushBroker 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;
foreach (var entry in IOS)
{
string dev = entry.Device_Id.ToString();
string load = entry.Push_Payload.ToString();
int count = entry.Unread_Count;
var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../productionfile.p12"));
push.RegisterAppleService(new ApplePushChannelSettings(true, appleCert, "password")); //Extension method
push.QueueNotification(new AppleNotification()
.ForDeviceToken(dev)
.WithAlert(load)
.WithBadge(count));
}
}
Run Code Online (Sandbox Code Playgroud)
消息发送成功,但是,我遇到的问题是1.尝试在消息发送成功或失败时检索响应,失败原因等...这些是pushsharp代码中的委托,以便我可以记录回复我们的数据库.为了澄清......我需要知道错误响应来自哪个条目尝试(deviceID).由于数据未链接到任何特定的deviceid传递尝试,因此我无法通知来自通知发布的代理的生成的消息.2.我还希望能够保持pushsharp代码不受修改并从我的代码中调用方法,以便在将来对pushsharp代码进行任何更新时减少合并问题.有什么建议?如果有人可以给我任何关于如何使用响应事件和代理来检索每个通知发送尝试的信息的示例,我将不胜感激.谢谢.