似乎每个人都使用PushSharp从C#向iOS设备发送推送通知.但是该库有一个它使用的队列,而不是直接发送通知,这意味着您需要一个Windows服务或其他东西来正确托管它(根据自己的文档)这对我来说是过度的.我有一个传入Web请求到我的ASP.NET Web服务,作为处理它的一部分,我想立即发送推送通知.就那么简单.
任何人都可以告诉我如何使用PushSharp立即发送一个(绕过其队列机制)或如何正确发送推送通知自己?我已经有了制定JSON消息的代码,但我不知道如何将.p12文件应用于请求.我找不到任何Apple文档来说明如何做到这一点.
我目前正在使用ionic/ngcordova构建一个android应用程序.我正在实施推送通知.我已经将推送通知实现为在app.run(function(){..})阶段注入的服务.注册部分工作,我收到一个包含该回调的回调regid.此外,当应用程序处于活动状态时,将引发事件并接收通知.
我遇到的问题是,当应用程序进入后台时,根本不会收到通知.我希望当应用程序没有运行或类似的东西时会引发本地通知,但绝对没有任何反应,这很奇怪.
我最近几天在网上搜寻寻找解决方案,但我一直无法找到任何能告诉我它应该工作的东西.
以下是我的app中的notificationService.js
app.factory('notificationService', ['$cordovaPush', function($cordovaPush){
var dataFactory = {};
//
// When the device is ready and this service has been plumbed in...
document.addEventListener("deviceready", function(){
console.log("initializing push notifications...");
_register();
}, false);
//
// Registers the device for push notifications...
var _register = function(){
var config = {};
if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){
// TODO: centralise this value as it can change...
config = {
senderID: …Run Code Online (Sandbox Code Playgroud) push-notification pushsharp ionic-framework phonegap-pushplugin ngcordova
我是PushSharp的新手,并试图了解如何使用它.
我有一种情况,我有一个苹果应用程序的不同版本.例如:MyApp,MyAppHD,MyAppPremium,MyAppPremiumHD.我有这些和4种不同的推送证书的不同的包标识符.
当我收集设备pushid时,我知道哪个属于哪个包标识符.
我的问题是,如果我在PushSharp中使用它,我是否会创建4个不同的PushService实例?或者我是否向一个PushService添加4个Apple频道?
如果我能够使用4个频道,如何指定特定设备属于哪个频道?
如果我创建多个实例,我想知道是否有重大的性能影响,或者此时无关紧要?
谢谢杰克
我想写发送和使用作为概括GCM的CCS接收来自Android设备的通知第三方服务器应用程序在这里.我正在利用PushSharp处理从我的服务器应用程序发送通知,但我似乎无法找到有关如何在服务器级别接收消息的任何文档.是否支持或是否有另一个用于.NET的第三方XMPP库可以干净地处理这个问题?
我正在使用Push Sharp库将推送通知发送到Apple APN服务器.代码效果很好,我可以发送1000个通知.
问题是,如果我尝试发送带有无效设备令牌的通知,我会收到来自push sharp框架的失败消息,pushsharp.apple.notificationfailureexception并且不会发送在该点之后排队的每个消息.基本上,如果单个通知失败,PushSharp将清除其队列.
例如,如果我排队4个通知(1,2,3,4)并且通知2具有无效的设备令牌,则将发送通知1,2将失败,并且不发送3和4(并且不会触发任何事件通知这个的).
我知道带有无效设备令牌的通知将不会被发送,但是不能接受将其他N个排队通知丢弃在地板上.
这有什么变通方法吗?
这是我的代码:
_appleSettings = new ApplePushChannelSettings(!NOTIFICATION_SERVICE_USE_DEVELOPMENT,
NOTIFICATION_SERVICE_USE_DEVELOPMENT
? SSL_CERTIFICATE_NAME_DEV : SSL_CERTIFICATE_NAME_PROD,
SSL_CERTIFICATE_PASSWORD);
_appleSettings.ConnectionTimeout = NOTIFICATION_SERVICE_CONNECTION_TIMEOUT;
_appleSettings.FeedbackIntervalMinutes = 0; /*WE WILL HANDLE THE FEEDBACK EXTERNALLY*/
_appleSettings.MaxConnectionAttempts = NOTIFICATION_SERVICE_RETRY_ATTEMPS;
_serviceSettings = new PushServiceSettings();
_serviceSettings.MaxAutoScaleChannels = NOTIFICATION_SERVICE_NUM_CONNECTIONS;
_pushBroker = new PushBroker();
_pushBroker.OnChannelCreated += _pushBroker_OnChannelCreated;
_pushBroker.OnChannelDestroyed += _pushBroker_OnChannelDestroyed;
_pushBroker.OnChannelException += _pushBroker_OnChannelException;
_pushBroker.OnDeviceSubscriptionChanged += _pushBroker_OnDeviceSubscriptionChanged;
_pushBroker.OnDeviceSubscriptionExpired += _pushBroker_OnDeviceSubscriptionExpired;
_pushBroker.OnNotificationFailed += _pushBroker_OnNotificationFailed;
_pushBroker.OnNotificationRequeue += _pushBroker_OnNotificationRequeue;
_pushBroker.OnNotificationSent += _pushBroker_OnNotificationSent;
_pushBroker.OnServiceException += _pushBroker_OnServiceException; …Run Code Online (Sandbox Code Playgroud) 我想讨论的主题可能是这个问题的重复。但我仍然对Apple 推送通知有一些疑问。
我有一款同时支持 Android 和 iOS 的应用程序。该应用程序需要一个后台服务,每分钟都会访问一次远程服务器。这项工作对于 Android 应用程序来说很简单,但由于 iOS 不支持后台任务,我需要为 iOS 应用程序使用推送通知。我正在使用PushSharp库来发送推送通知。苹果表示,推送通知的发送并未得到确认。我无法承受推送通知失败的后果,因为我需要通过通知发送非常重要的消息。我的问题是:
1)推送通知的失败率是多少?
2) 推送通知是否始终可靠地发送重要消息?
3) 假设发送推送通知的服务器每分钟发送大量推送通知。在这种情况下推送通知失败的可能性有多大?
4)哪些情况会导致推送失败?
如果您有任何有用的资源,请提供相同的资源。谢谢。
我收到以下错误"身份验证失败,因为远程方已关闭传输流"
在ling代码之后:stream.AuthenticateAsClient(this.appleSettings.Host,this.certificates,System.Security.Authentication.SslProtocols.Ssl3,false);
它有意义的p.12
void connect()
{
client = new TcpClient();
//Notify we are connecting
var eoc = this.OnConnecting;
if (eoc != null)
eoc(this.appleSettings.Host, this.appleSettings.Port);
try
{
client.Connect(this.appleSettings.Host, this.appleSettings.Port);
}
catch (Exception ex)
{
throw new ConnectionFailureException("Connection to Host Failed", ex);
}
if (appleSettings.SkipSsl)
{
networkStream = client.GetStream();
}
else
{
stream = new SslStream(client.GetStream(), false,
new RemoteCertificateValidationCallback((sender, cert, chain, sslPolicyErrors) => { return true; }),
new LocalCertificateSelectionCallback((sender, targetHost, localCerts, remoteCert, acceptableIssuers) =>
{
return certificate;
}));
try
{
stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, …Run Code Online (Sandbox Code Playgroud) 我开发了Windows服务,使用pushsharp库向iOS和Android应用程序发送推送通知.最近我将库从2.xx更新到4.0.10并且GCM通知发送正常但Ios通知没有发送,总是得到"连接错误"我需要向数千个令牌发送通知,所以我循环遍历所有代币和排队.即使是10个令牌也会得到同样的错误.请告诉我我的代码有什么问题.这是我的代码片段
public static void SendNotifications(List currentBrandNotications, long brandId)
{
byte[] appleCert = null;
string p12File = @"aps_production_brand" + brandId.ToString().Trim() + ".p12";
try
{
appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "P12\\" + p12File));
}
catch (Exception ex)
{
logger.Debug("P12 certificate is not avilable for BrandId: " + brandId);
}
try
{
logger.Debug(" Send PushNotifications To Apple :- ");
if (appleCert != null)
{
// Configuration
var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production, appleCert, currentBrandNotications[0].P12Password);
// Create a new broker
var apnsBroker = new ApnsServiceBroker(config);
var fbs …Run Code Online (Sandbox Code Playgroud) 我正在使用PushSharp 4.0.10,MVC 4和c#
在Apns代理的OnNotificationFailed事件中,我得到了ConnectionError异常.
更改证书(.p12)文件后突然发生此异常; 在这次改变之前它运作良好.
请告知如何解决此错误.
var certificate = System.IO.File.ReadAllBytes(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Mobile/consumer_dev.p12"));
var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, certificate, "", true);
var apnsBroker = new ApnsServiceBroker(config);
apnsBroker.OnNotificationFailed += (notification, aggregateEx) => {
aggregateEx.Handle (ex => {
if (ex is ApnsNotificationException) {
var notificationException = (ApnsNotificationException)ex;
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;
Debug.WriteLine(apnsNotification.Identifier + ", " + statusCode);
} else {
Debug.WriteLine(ex.InnerException);
}
return true;
});
};
apnsBroker.OnNotificationSucceeded += (notification) => {
Debug.WriteLine("Apple Notification Sent!");
};
apnsBroker.Start();
foreach (var deviceToken in …Run Code Online (Sandbox Code Playgroud) 我正在使用 Firebase Cloud Messaging 向 IOS 和 Android 设备发送推送通知。我想在邮件正文中发送一些文本,其中一部分是粗体的。这就是我的 Android 推送通知的 JSON 现在的样子:
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification":{
"body":"Some plain text THIS TEXT SHOULD BE BOLD some plain text"
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想在推送通知中看到这样的消息:“一些纯文本此文本应该是粗体一些纯文本”
可以这样做吗?
push-notification firebase pushsharp firebase-cloud-messaging