olofd / react-native-signalr

Use SignalR with React Native
150 stars 61 forks source link

How to send token or other data #55

Open wojtekhorembala opened 5 years ago

wojtekhorembala commented 5 years ago

Hi, in the web application I use signalR for angular (https://www.npmjs.com/package/@aspnet/signalr)

When i connected, I send token, example from web app. (accessTokenFactory)

this.notifyHubConnection = new signalR.HubConnectionBuilder()
 .withUrl(`${ this.apiUrl }hub/messages`, { accessTokenFactory: () => token })
 .build();
this.notifyHubConnection.start().catch((err) => this.hubReconnect());
this.notifyHubConnection.on('OnMessageReceived', (sender, senderID, content) => {...});

This is what my code looks like in a web application, can anyone help me open it in this library?

SowinskiMateusz commented 5 years ago

I have the same problem.

SowinskiMateusz commented 5 years ago

Propably I found the solution:

const connection = signalr.hubConnection('url', { headers: { 'Authorization':Bearer ${valueObj.token}, 'Content-Type': 'text/plain;charset=UTF-8' } }

wojtekhorembala commented 5 years ago

I used lib from microsoft and this run :P https://docs.microsoft.com/pl-pl/aspnet/core/signalr/javascript-client?view=aspnetcore-2.2