-
Notifications
You must be signed in to change notification settings - Fork 225
Open
Description
Im new to Flutter frameWork
I want to use signalr on flutter to connect to a server and receive notification
below code is how I do it on Java:
Platform.loadPlatformComponent(new AndroidPlatformComponent());
Credentials credentials = new Credentials() {
@Override
public void prepareRequest(Request request) {
request.addHeader("username", userId);
}
};
String serverUrl = "http://www.xxxxx.org/";
mHubConnection = new HubConnection(serverUrl);
mHubConnection.setCredentials(credentials);
String SERVER_HUB_CHAT = "notificationHub";
mHubProxy = mHubConnection.createHubProxy(SERVER_HUB_CHAT);
ClientTransport clientTransport = new ServerSentEventsTransport(mHubConnection.getLogger());
SignalRFuture<Void> signalRFuture = mHubConnection.start(clientTransport);
try {
signalRFuture.get();
} catch (Exception ex) {
UtilFunctions.showToastMessage(getApplicationContext(), ex);
return;
}
String SERVER_METHOD_SEND = "SendNotifications";
mHubProxy.invoke(SERVER_METHOD_SEND);
mHubProxy.on("ReceiveNotification", new SubscriptionHandler1<String>() {
@Override
public void run(final String string) {
......
}
}, String.class);
But Im not able to implement on flutter
ppreciate any help.
Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels