请我有一个问题,当我尝试向 Android 设备发送推送通知时,我可以轻松绑定(bind)从 appsettings 中发送的 senderId 和 ServerKey key ,我从 firebase 控制台获取它,然后通过 FcmSender 传递它,它可以成功工作。
var fcm = new FcmSender(settings, httpClient);
await fcm.SendAsync(deviceToken, notification);
我的问题是,当我尝试向 ios 设备发送推送通知时,我总是收到 BadDeviceToken,但同时我可以从 firebase 控制台成功向此 fcm 发送推送通知。 是我的应用服务器的错误吗?
谢谢
最佳答案
您可以使用 CorePush 发送 iOS 通知。我正在使用 CorePush 3.0.0。之前我尝试过 CorePush 3.1.1,但它给我带来了 Json 解析问题
AppleNotification NotificationMessage = new AppleNotification();
NotificationMessage.Data = data;
NotificationMessage.Aps = new ApsPayload() { AlertBody = "my body" };
ApnSettings settingsApn = new ApnSettings()
{
AppBundleIdentifier = "com.iwish.developerscloud",
P8PrivateKey = "p8 certificate generated in itunes,string without spaces, ----- or line breaks",
P8PrivateKeyId = "10 digit p8 certificate id. Usually a part of a downloadable certificate filename",
ServerType = ApnServerType.Development,
TeamId = "You Apple Team ID"
};
var apn = new ApnSender(settingsApn, _http);
apnResponse = apn.SendAsync(NotificationMessage, token.DeviceToken).Result;
我也在分享 AppleNotification Model 类
public class AppleNotification
{
[JsonProperty("aps")]
public ApsPayload Aps { get; set; }
// Your custom properties as needed
[JsonProperty("data")]
public DataPayload_PushNotification Data { get; set; }
}
public class ApsPayload
{
[JsonProperty("alert")]
public string AlertBody { get; set; }
}
关于asp.net-core - 核心推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72890732/