SendBird .NET SDK 提供了两种推送注册方法,因为它可以在 Android 和 iOS 中使用。
Android:RegisterFCMPushTokenForCurrentUser
iOS:RegisterAPNSPushTokenForCurrentUser
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.
}
});
});