1

I'm implementing Sendbird on a Xamarin.iOS application, and I already receive messages, on the OnMessageReceived handler.

But I'm unable to receive push notifications, the GetPendingPushToken() always returns null, so in the RegisterAPNSPushTokenForCurrentUser() method I just pass a string with the device token. And registers the user token on SendBird dashboard like this:

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

I have notice that in the .NET SDK I don't have access to the method registerDevicePushToken() that is available in the iOS SDK and in the samples is implemented inside the didRegisterForRemoteNotificationsWithDeviceToken() method.

The APNS is properly set on the SendBird dashboard, and I already receive push notification on the device from another API.

João Palma
  • 66
  • 11

1 Answers1

0

SendBird .NET SDK provides two push registration methods because it could be used in both Android and 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.
        }

    });
});
Harry Kim
  • 89
  • 5
  • I know how to read the sendbird documents, and if you read my problem you also see that Im already using those methods. The problem is that getpendingpushtoken is always null – João Palma Sep 14 '18 at 10:06
  • Written Above code in my project as well but this line **if (SendBirdClient.GetPendingPushToken() == null) return;** always **true** and it returns control from here. – Naveen Tiwari Nov 06 '18 at 05:30
  • yep, im using onesignal for push notifications, if you find a solution pls tell me. – João Palma Nov 06 '18 at 10:03