我正在 Xamarin.iOS 应用程序上实现 Sendbird,并且我已经在 OnMessageReceived 处理程序上接收消息。
但是我无法接收推送通知,GetPendingPushToken() 总是返回 null,所以在 RegisterAPNSPushTokenForCurrentUser() 方法中我只是传递了一个 string使用设备 token 。并像这样在 SendBird 仪表板上注册用户 token :
"05d0c16a 52328ef2 973b29bb 91556ed6 59dcb340 321dc3e6 b0842c20 6e5190d2".
我注意到在 .NET SDK 中我无法访问 registerDevicePushToken() 方法,而在 iOS SDK中可用em> 并且在示例中是在 didRegisterForRemoteNotificationsWithDeviceToken() 方法中实现的。
APNS 已在 SendBird 仪表板上正确设置,我已经在设备上收到来自另一个 API 的推送通知。
最佳答案
SendBird .NET SDK提供两种推送注册方式,Android和iOS均可使用。
安卓:注册FCMPushTokenForCurrentUser
iOS:注册APNSPushTokenForCurrentUser
SendBirdClient.Connect(userId, (User user, SendBirdException e) => {
if (e != null) {
// Error.
return;
}
if (SendBirdClient.GetPendingPushToken() == null) return;
// For Android
SendBirdClient.RegisterFCMPushTokenForCurrentUser(SendBirdClient.GetPendingPushToken(), (SendBirdClient.PushTokenRegistrationStatus status, SendBirdException e1) => {
if (e1 != null) {
// Error.
return;
}
if (status == SendBirdClient.PushTokenRegistrationStatus.PENDING) {
// Try registration after connection is established.
}
});
// For iOS
SendBirdClient.RegisterAPNSPushTokenForCurrentUser(SendBirdClient.GetPendingPushToken(), (SendBirdClient.PushTokenRegistrationStatus status, SendBirdException e1) => {
if (e1 != null) {
// Error.
return;
}
if (status == SendBirdClient.PushTokenRegistrationStatus.PENDING) {
// Try registration after connection is established.
}
});
});
关于ios - Sendbird 未收到推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52285618/