react-native-pusher-push-notifications icon indicating copy to clipboard operation
react-native-pusher-push-notifications copied to clipboard

setUserId seems to require a token parameter

Open daveslutzkin opened this issue 4 years ago • 1 comments
trafficstars

setUserId has the signature:

setUserId: (userId, token, onError, onSuccess)

but nothing in the library returns the device token (which I assume is what that is)?

If that's required then the library should presumably return the token in the registered callback?

The appropriate code would be something like:

- (void)setDeviceToken:(NSData *)deviceToken
{
    RCTLogInfo(@"setDeviceToken: %@", deviceToken);
    [[PushNotifications shared] registerDeviceToken:deviceToken];
    [RNPusherEventHelper emitEventWithName:@"registered" andPayload:@{
      @"deviceToken":deviceToken
    }];
    RCTLogInfo(@"REGISTERED!");
}

daveslutzkin avatar Jul 07 '21 10:07 daveslutzkin

The server SDK libraries have a function that generates this token. In our app, I pass the user_uuid attribute to an API request and it gives me back the generated pusher token. Then I call setUserId with these two parameters to bind the logged user.

gabrielbezerra81 avatar Jul 20 '21 17:07 gabrielbezerra81