ios - Sendbird 未收到推送通知

标签 ios xamarin push-notification xamarin.ios sendbird

我正在 Xamarin.iOS 应用程序上实现 Sendbird,并且我已经在 OnMessageReceived 处理程序上接收消息。

但是我无法接收推送通知,GetPendingPushToken() 总是返回 null,所以在 RegisterAPNSPushTokenForCurrentUser() 方法中我只是传递了一个 string使用设备 token 。并像这样在 SendBird 仪表板上注册用户 token :

"05d0c16a 52328ef2 973b29bb 91556ed6 59dcb340 321dc3e6 b0842c20 6e5190d2".

我注意到在 .NET SDK 中我无法访问 registerDevicePushToken() 方法,而在 iOS SDK 并且在示例中是在 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/

相关文章:

iphone - 如何查看给定 iOS ipa 文件中定义的 NSString

c# - SetColorFilter 在 Xamarin.Android 中不起作用

android - 是否有可能使基于 android webview 的应用程序在将点击解释为小拖动时不那么敏感?

c# - Xamarin.Forms.Labs - ListView 中的复选框在 Windows Phone 8 上不起作用?

android - 当应用程序在后台使用 firebase 时,使推送通知显示为弹出窗口

iOS 推送通知句柄

ios - 为什么我总是在ios中获得缓存的位置

ios - 在 swift 3 中使用 UISearchBar/UISearchController 进行即时搜索

iOS 应用程序在后台运行并在插入联系人时收到通知

iOS 推送通知 didFailToRegisterForRemoteNotificationsWithError