react-native-pusher-push-notifications
react-native-pusher-push-notifications copied to clipboard
setUserId seems to require a token parameter
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!");
}
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.