【问题标题】:Sendbird Not Receiving push notificationsSendbird 未收到推送通知
【发布时间】:2019-02-16 12:44:20
【问题描述】:

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

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

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

我注意到在 .NET SDK 中我无法访问 iOS SDK 中提供的方法 registerDevicePushToken() em> 并且在示例中是在 didRegisterForRemoteNotificationsWithDeviceToken() 方法中实现的。

在 SendBird 仪表板上正确设置了 APNS,并且我已经在设备上收到了来自另一个 API 的推送通知。

【问题讨论】:

  • 我这边也面临同样的问题 GetPendingPushToken() 总是返回 null

标签: ios xamarin push-notification xamarin.ios sendbird


【解决方案1】:

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.
        }

    });
});

【讨论】:

  • 我知道如何阅读 sendbird 文档,如果您阅读了我的问题,您还会发现我已经在使用这些方法。问题是 getpendingpushtoken 始终为空
  • 在我的项目中也写了上面的代码,但是这一行 if (SendBirdClient.GetPendingPushToken() == null) return; 总是 true 并且它从这里返回控制权。
  • 是的,我使用 onesignal 推送通知,如果你找到解决方案请告诉我。
猜你喜欢
  • 2019-04-04
  • 2011-08-23
  • 2018-06-16
  • 2014-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多