asp.net-core - 核心推送通知

标签 asp.net-core firebase-cloud-messaging

请我有一个问题,当我尝试向 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/

相关文章:

c# - 是否可以从组件继承 Razor 标记?

android - 收到消息时,Android 上的 Firebase 消息突然开始崩溃

android - 发送一个通知后未注册的 token 错误

javascript - firebase函数onwrite的值有时为null

asp.net-web-api - ASP.NET 核心 Web API : Why need ModelState validation in Get request?

c# - Redis StackExchange 删除键

asp.net-core - .NET & Swagger 开始出现 401 错误

asp.net-core - .Net核心 View : the name "Layout" does not exist in the current context

javascript - FCM 通知适用于 Chrome 但不适用于 Firefox

firebase - 为什么我的 Xamarin.iOS 应用程序没有收到来自 Google Firebase 的推送通知?