diff --git a/.metadata b/.metadata index cae5295..5bed526 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: bbfbf1770cca2da7c82e887e4e4af910034800b6 + revision: 18116933e77adc82f80866c928266a5b4f1ed645 channel: stable project_type: plugin diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 8e58131..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "signalr_flutter", - "request": "launch", - "type": "dart" - }, - { - "name": "example", - "cwd": "example", - "request": "launch", - "type": "dart" - }, - { - "name": "example-release", - "cwd": "example", - "request": "launch", - "type": "dart", - "flutterMode": "release" - }, - { - "name": "example-profile", - "cwd": "example", - "request": "launch", - "type": "dart", - "flutterMode": "profile" - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a9d2ec..0f276b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,4 +55,41 @@ ## 0.1.2 -* IsConnected Method Added \ No newline at end of file +* IsConnected Method Added + +## 0.2.0-dev.1 + +* Rewrote the plugin using pigeon +* **Breaking Changes**: + * `invokeMethod` now take only strings as arguments instead of dynamic. + * `invokeMethod` now returns only string as result. + * `hubCallback` now also returns string as message instead of dynamic. + +## 0.2.0-dev.2 + +* Fix for invokeMethod calls having no return value. + +## 0.2.0-dev.3 + +* Updated signalr for iOS. +* Transport fallback properly added for iOS. + +## 0.2.0-dev.4 + +* App bundle build issue fix. + +## 0.2.0-dev.5 + +* Removed unnecessary platform exceptions. +* Updated dependencies. + +## 0.2.0 + +* Rewrote the plugin using pigeon. +* Removed unnecessary platform exceptions. +* Updated signalr for iOS. +* Updated all dependencies to the latest. +* **Breaking Changes**: + * `invokeMethod` now take only strings as arguments instead of dynamic. + * `invokeMethod` now returns only string as result. + * `hubCallback` now also returns string as message instead of dynamic. \ No newline at end of file diff --git a/LICENSE b/LICENSE index bb5d2b9..9a96069 100644 --- a/LICENSE +++ b/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index d85f9cb..01603ea 100644 --- a/README.md +++ b/README.md @@ -49,3 +49,4 @@ R8 may strip away some SignalR classes for the Android in Release Builds. Add th For more info check example. Any issue or PR is always welcome. + diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.idea/.name b/android/.idea/.name deleted file mode 100644 index 124c49d..0000000 --- a/android/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -signalr_flutter \ No newline at end of file diff --git a/android/.idea/caches/build_file_checksums.ser b/android/.idea/caches/build_file_checksums.ser deleted file mode 100644 index 004c910..0000000 Binary files a/android/.idea/caches/build_file_checksums.ser and /dev/null differ diff --git a/android/.idea/codeStyles/Project.xml b/android/.idea/codeStyles/Project.xml deleted file mode 100644 index 0d15693..0000000 --- a/android/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - -
- - - - xmlns:android - - ^$ - - - -
-
- - - - xmlns:.* - - ^$ - - - BY_NAME - -
-
- - - - .*:id - - http://schemas.android.com/apk/res/android - - - -
-
- - - - .*:name - - http://schemas.android.com/apk/res/android - - - -
-
- - - - name - - ^$ - - - -
-
- - - - style - - ^$ - - - -
-
- - - - .* - - ^$ - - - BY_NAME - -
-
- - - - .* - - http://schemas.android.com/apk/res/android - - - ANDROID_ATTRIBUTE_ORDER - -
-
- - - - .* - - .* - - - BY_NAME - -
-
-
-
-
-
\ No newline at end of file diff --git a/android/.idea/gradle.xml b/android/.idea/gradle.xml deleted file mode 100644 index 5a9f2bf..0000000 --- a/android/.idea/gradle.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/.idea/jarRepositories.xml b/android/.idea/jarRepositories.xml deleted file mode 100644 index a5f05cd..0000000 --- a/android/.idea/jarRepositories.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/.idea/misc.xml b/android/.idea/misc.xml deleted file mode 100644 index 37a7509..0000000 --- a/android/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/android/.idea/modules.xml b/android/.idea/modules.xml deleted file mode 100644 index ccb2972..0000000 --- a/android/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/android/.idea/runConfigurations.xml b/android/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/android/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 03b523b..41cd8d2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'dev.asdevs.signalr_flutter' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.4.21' + ext.kotlin_version = '1.7.20' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.2' + classpath 'com.android.tools.build:gradle:7.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -17,7 +17,7 @@ buildscript { rootProject.allprojects { repositories { google() - jcenter() + mavenCentral() } } @@ -25,22 +25,29 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 30 + compileSdkVersion 33 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' } + defaultConfig { minSdkVersion 16 } - lintOptions { - disable 'InvalidPackage' - } } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.google.code.gson:gson:2.8.6' - compile files('libs/signalr-client-sdk.jar') - compile files('libs/signalr-client-sdk-android.jar') + implementation 'com.google.code.gson:gson:2.8.9' + implementation files('libraries/signalr-client-sdk.jar') + implementation files('libraries/signalr-client-sdk-android.jar') } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 735acdd..3c9d085 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sun Aug 23 12:49:17 IST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/android/libs/signalr-client-sdk-android.jar b/android/libraries/signalr-client-sdk-android.jar similarity index 100% rename from android/libs/signalr-client-sdk-android.jar rename to android/libraries/signalr-client-sdk-android.jar diff --git a/android/libs/signalr-client-sdk.jar b/android/libraries/signalr-client-sdk.jar similarity index 77% rename from android/libs/signalr-client-sdk.jar rename to android/libraries/signalr-client-sdk.jar index f736f64..cc52b84 100644 Binary files a/android/libs/signalr-client-sdk.jar and b/android/libraries/signalr-client-sdk.jar differ diff --git a/android/src/main/java/dev/asdevs/signalr_flutter/SignalrApi.java b/android/src/main/java/dev/asdevs/signalr_flutter/SignalrApi.java new file mode 100644 index 0000000..74b1c24 --- /dev/null +++ b/android/src/main/java/dev/asdevs/signalr_flutter/SignalrApi.java @@ -0,0 +1,491 @@ +// Autogenerated from Pigeon (v4.2.5), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package dev.asdevs.signalr_flutter; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +/**Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class SignalrApi { + + /** Transport method of the signalr connection. */ + public enum Transport { + AUTO(0), + SERVER_SENT_EVENTS(1), + LONG_POLLING(2); + + private int index; + private Transport(final int index) { + this.index = index; + } + } + + /** SignalR connection status */ + public enum ConnectionStatus { + CONNECTING(0), + CONNECTED(1), + RECONNECTING(2), + DISCONNECTED(3), + CONNECTION_SLOW(4), + CONNECTION_ERROR(5); + + private int index; + private ConnectionStatus(final int index) { + this.index = index; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class ConnectionOptions { + private @Nullable String baseUrl; + public @Nullable String getBaseUrl() { return baseUrl; } + public void setBaseUrl(@Nullable String setterArg) { + this.baseUrl = setterArg; + } + + private @Nullable String hubName; + public @Nullable String getHubName() { return hubName; } + public void setHubName(@Nullable String setterArg) { + this.hubName = setterArg; + } + + private @Nullable String queryString; + public @Nullable String getQueryString() { return queryString; } + public void setQueryString(@Nullable String setterArg) { + this.queryString = setterArg; + } + + private @Nullable List hubMethods; + public @Nullable List getHubMethods() { return hubMethods; } + public void setHubMethods(@Nullable List setterArg) { + this.hubMethods = setterArg; + } + + private @Nullable Map headers; + public @Nullable Map getHeaders() { return headers; } + public void setHeaders(@Nullable Map setterArg) { + this.headers = setterArg; + } + + private @Nullable Transport transport; + public @Nullable Transport getTransport() { return transport; } + public void setTransport(@Nullable Transport setterArg) { + this.transport = setterArg; + } + + public static final class Builder { + private @Nullable String baseUrl; + public @NonNull Builder setBaseUrl(@Nullable String setterArg) { + this.baseUrl = setterArg; + return this; + } + private @Nullable String hubName; + public @NonNull Builder setHubName(@Nullable String setterArg) { + this.hubName = setterArg; + return this; + } + private @Nullable String queryString; + public @NonNull Builder setQueryString(@Nullable String setterArg) { + this.queryString = setterArg; + return this; + } + private @Nullable List hubMethods; + public @NonNull Builder setHubMethods(@Nullable List setterArg) { + this.hubMethods = setterArg; + return this; + } + private @Nullable Map headers; + public @NonNull Builder setHeaders(@Nullable Map setterArg) { + this.headers = setterArg; + return this; + } + private @Nullable Transport transport; + public @NonNull Builder setTransport(@Nullable Transport setterArg) { + this.transport = setterArg; + return this; + } + public @NonNull ConnectionOptions build() { + ConnectionOptions pigeonReturn = new ConnectionOptions(); + pigeonReturn.setBaseUrl(baseUrl); + pigeonReturn.setHubName(hubName); + pigeonReturn.setQueryString(queryString); + pigeonReturn.setHubMethods(hubMethods); + pigeonReturn.setHeaders(headers); + pigeonReturn.setTransport(transport); + return pigeonReturn; + } + } + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("baseUrl", baseUrl); + toMapResult.put("hubName", hubName); + toMapResult.put("queryString", queryString); + toMapResult.put("hubMethods", hubMethods); + toMapResult.put("headers", headers); + toMapResult.put("transport", transport == null ? null : transport.index); + return toMapResult; + } + static @NonNull ConnectionOptions fromMap(@NonNull Map map) { + ConnectionOptions pigeonResult = new ConnectionOptions(); + Object baseUrl = map.get("baseUrl"); + pigeonResult.setBaseUrl((String)baseUrl); + Object hubName = map.get("hubName"); + pigeonResult.setHubName((String)hubName); + Object queryString = map.get("queryString"); + pigeonResult.setQueryString((String)queryString); + Object hubMethods = map.get("hubMethods"); + pigeonResult.setHubMethods((List)hubMethods); + Object headers = map.get("headers"); + pigeonResult.setHeaders((Map)headers); + Object transport = map.get("transport"); + pigeonResult.setTransport(transport == null ? null : Transport.values()[(int)transport]); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class StatusChangeResult { + private @Nullable String connectionId; + public @Nullable String getConnectionId() { return connectionId; } + public void setConnectionId(@Nullable String setterArg) { + this.connectionId = setterArg; + } + + private @Nullable ConnectionStatus status; + public @Nullable ConnectionStatus getStatus() { return status; } + public void setStatus(@Nullable ConnectionStatus setterArg) { + this.status = setterArg; + } + + private @Nullable String errorMessage; + public @Nullable String getErrorMessage() { return errorMessage; } + public void setErrorMessage(@Nullable String setterArg) { + this.errorMessage = setterArg; + } + + public static final class Builder { + private @Nullable String connectionId; + public @NonNull Builder setConnectionId(@Nullable String setterArg) { + this.connectionId = setterArg; + return this; + } + private @Nullable ConnectionStatus status; + public @NonNull Builder setStatus(@Nullable ConnectionStatus setterArg) { + this.status = setterArg; + return this; + } + private @Nullable String errorMessage; + public @NonNull Builder setErrorMessage(@Nullable String setterArg) { + this.errorMessage = setterArg; + return this; + } + public @NonNull StatusChangeResult build() { + StatusChangeResult pigeonReturn = new StatusChangeResult(); + pigeonReturn.setConnectionId(connectionId); + pigeonReturn.setStatus(status); + pigeonReturn.setErrorMessage(errorMessage); + return pigeonReturn; + } + } + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("connectionId", connectionId); + toMapResult.put("status", status == null ? null : status.index); + toMapResult.put("errorMessage", errorMessage); + return toMapResult; + } + static @NonNull StatusChangeResult fromMap(@NonNull Map map) { + StatusChangeResult pigeonResult = new StatusChangeResult(); + Object connectionId = map.get("connectionId"); + pigeonResult.setConnectionId((String)connectionId); + Object status = map.get("status"); + pigeonResult.setStatus(status == null ? null : ConnectionStatus.values()[(int)status]); + Object errorMessage = map.get("errorMessage"); + pigeonResult.setErrorMessage((String)errorMessage); + return pigeonResult; + } + } + + public interface Result { + void success(T result); + void error(Throwable error); + } + private static class SignalRHostApiCodec extends StandardMessageCodec { + public static final SignalRHostApiCodec INSTANCE = new SignalRHostApiCodec(); + private SignalRHostApiCodec() {} + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte)128: + return ConnectionOptions.fromMap((Map) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + + } + } + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof ConnectionOptions) { + stream.write(128); + writeValue(stream, ((ConnectionOptions) value).toMap()); + } else +{ + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface SignalRHostApi { + void connect(@NonNull ConnectionOptions connectionOptions, Result result); + void reconnect(Result result); + void stop(Result result); + void isConnected(Result result); + void invokeMethod(@NonNull String methodName, @NonNull List arguments, Result result); + + /** The codec used by SignalRHostApi. */ + static MessageCodec getCodec() { + return SignalRHostApiCodec.INSTANCE; } + /**Sets up an instance of `SignalRHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, SignalRHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.SignalRHostApi.connect", getCodec()); + if (api != null) { + channel.setMessageHandler((message, reply) -> { + Map wrapped = new HashMap<>(); + try { + ArrayList args = (ArrayList)message; + assert args != null; + ConnectionOptions connectionOptionsArg = (ConnectionOptions)args.get(0); + if (connectionOptionsArg == null) { + throw new NullPointerException("connectionOptionsArg unexpectedly null."); + } + Result resultCallback = new Result() { + public void success(String result) { + wrapped.put("result", result); + reply.reply(wrapped); + } + public void error(Throwable error) { + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); + } + }; + + api.connect(connectionOptionsArg, resultCallback); + } + catch (Error | RuntimeException exception) { + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.SignalRHostApi.reconnect", getCodec()); + if (api != null) { + channel.setMessageHandler((message, reply) -> { + Map wrapped = new HashMap<>(); + try { + Result resultCallback = new Result() { + public void success(String result) { + wrapped.put("result", result); + reply.reply(wrapped); + } + public void error(Throwable error) { + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); + } + }; + + api.reconnect(resultCallback); + } + catch (Error | RuntimeException exception) { + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.SignalRHostApi.stop", getCodec()); + if (api != null) { + channel.setMessageHandler((message, reply) -> { + Map wrapped = new HashMap<>(); + try { + Result resultCallback = new Result() { + public void success(Void result) { + wrapped.put("result", null); + reply.reply(wrapped); + } + public void error(Throwable error) { + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); + } + }; + + api.stop(resultCallback); + } + catch (Error | RuntimeException exception) { + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.SignalRHostApi.isConnected", getCodec()); + if (api != null) { + channel.setMessageHandler((message, reply) -> { + Map wrapped = new HashMap<>(); + try { + Result resultCallback = new Result() { + public void success(Boolean result) { + wrapped.put("result", result); + reply.reply(wrapped); + } + public void error(Throwable error) { + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); + } + }; + + api.isConnected(resultCallback); + } + catch (Error | RuntimeException exception) { + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.SignalRHostApi.invokeMethod", getCodec()); + if (api != null) { + channel.setMessageHandler((message, reply) -> { + Map wrapped = new HashMap<>(); + try { + ArrayList args = (ArrayList)message; + assert args != null; + String methodNameArg = (String)args.get(0); + if (methodNameArg == null) { + throw new NullPointerException("methodNameArg unexpectedly null."); + } + List argumentsArg = (List)args.get(1); + if (argumentsArg == null) { + throw new NullPointerException("argumentsArg unexpectedly null."); + } + Result resultCallback = new Result() { + public void success(String result) { + wrapped.put("result", result); + reply.reply(wrapped); + } + public void error(Throwable error) { + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); + } + }; + + api.invokeMethod(methodNameArg, argumentsArg, resultCallback); + } + catch (Error | RuntimeException exception) { + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + private static class SignalRPlatformApiCodec extends StandardMessageCodec { + public static final SignalRPlatformApiCodec INSTANCE = new SignalRPlatformApiCodec(); + private SignalRPlatformApiCodec() {} + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte)128: + return StatusChangeResult.fromMap((Map) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + + } + } + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof StatusChangeResult) { + stream.write(128); + writeValue(stream, ((StatusChangeResult) value).toMap()); + } else +{ + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class SignalRPlatformApi { + private final BinaryMessenger binaryMessenger; + public SignalRPlatformApi(BinaryMessenger argBinaryMessenger){ + this.binaryMessenger = argBinaryMessenger; + } + public interface Reply { + void reply(T reply); + } + /** The codec used by SignalRPlatformApi. */ + static MessageCodec getCodec() { + return SignalRPlatformApiCodec.INSTANCE; + } + public void onStatusChange(@NonNull StatusChangeResult statusChangeResultArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.SignalRPlatformApi.onStatusChange", getCodec()); + channel.send(new ArrayList(Collections.singletonList(statusChangeResultArg)), channelReply -> { + callback.reply(null); + }); + } + public void onNewMessage(@NonNull String hubNameArg, @NonNull String messageArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.SignalRPlatformApi.onNewMessage", getCodec()); + channel.send(new ArrayList(Arrays.asList(hubNameArg, messageArg)), channelReply -> { + callback.reply(null); + }); + } + } + @NonNull private static Map wrapError(@NonNull Throwable exception) { + Map errorMap = new HashMap<>(); + errorMap.put("message", exception.toString()); + errorMap.put("code", exception.getClass().getSimpleName()); + errorMap.put("details", "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorMap; + } +} diff --git a/android/src/main/kotlin/dev/asdevs/signalr_flutter/SignalR.kt b/android/src/main/kotlin/dev/asdevs/signalr_flutter/SignalR.kt deleted file mode 100644 index 3f4c404..0000000 --- a/android/src/main/kotlin/dev/asdevs/signalr_flutter/SignalR.kt +++ /dev/null @@ -1,162 +0,0 @@ -package dev.asdevs.signalr_flutter - -import android.os.Handler -import android.os.Looper -import io.flutter.plugin.common.MethodChannel.Result -import microsoft.aspnet.signalr.client.* -import microsoft.aspnet.signalr.client.hubs.HubConnection -import microsoft.aspnet.signalr.client.hubs.HubProxy -import microsoft.aspnet.signalr.client.transport.LongPollingTransport -import microsoft.aspnet.signalr.client.transport.ServerSentEventsTransport - -enum class CallMethod(val value: String) { - ConnectToServer("connectToServer"), - Reconnect("reconnect"), - Stop("stop"), - IsConnected("isConnected"), - ListenToHubMethod("listenToHubMethod"), - InvokeServerMethod("invokeServerMethod") -} - -object SignalR { - private lateinit var connection: HubConnection - private lateinit var hub: HubProxy - - fun connectToServer(url: String, hubName: String, queryString: String, headers: Map, transport: Int, hubMethods: List, result: Result) { - try { - connection = if (queryString.isEmpty()) { - HubConnection(url) - } else { - HubConnection(url, queryString, true, Logger { _: String, _: LogLevel -> - }) - } - - if (headers.isNotEmpty()) { - val cred = Credentials() { request -> - request.headers = headers - } - connection.credentials = cred - } - hub = connection.createHubProxy(hubName) - - hubMethods.forEach { methodName -> - hub.on(methodName, { res -> - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("NewMessage", listOf(methodName, res)) - } - }, Any::class.java) - } - - connection.connected { - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("ConnectionStatus", connection.state.name) - } - } - - connection.reconnected { - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("ConnectionStatus", connection.state.name) - } - } - - connection.reconnecting { - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("ConnectionStatus", connection.state.name) - } - } - - connection.closed { - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("ConnectionStatus", connection.state.name) - } - } - - connection.connectionSlow { - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("ConnectionStatus", "Slow") - } - } - - connection.error { handler -> - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("ConnectionStatus", handler.localizedMessage) - } - } - - when (transport) { - 1 -> connection.start(ServerSentEventsTransport(connection.logger)) - 2 -> connection.start(LongPollingTransport(connection.logger)) - else -> { - connection.start() - } - } - - result.success(true) - } catch (ex: Exception) { - result.error("Error", ex.localizedMessage, null) - } - } - - fun reconnect(result: Result) { - try { - connection.start() - } catch (ex: Exception) { - result.error(ex.localizedMessage, ex.stackTrace.toString(), null) - } - } - - fun stop(result: Result) { - try { - connection.stop() - } catch (ex: Exception) { - result.error(ex.localizedMessage, ex.stackTrace.toString(), null) - } - } - - fun isConnected(result: Result) { - try { - if (this::connection.isInitialized) { - when (connection.state) { - ConnectionState.Connected -> result.success(true) - else -> result.success(false) - } - } else { - result.success(false) - } - } catch (ex: Exception) { - result.error("Error", ex.localizedMessage, null) - } - } - - fun listenToHubMethod(methodName: String, result: Result) { - try { - hub.on(methodName, { res -> - Handler(Looper.getMainLooper()).post { - SignalRFlutterPlugin.channel.invokeMethod("NewMessage", listOf(methodName, res)) - } - }, Any::class.java) - } catch (ex: Exception) { - result.error("Error", ex.localizedMessage, null) - } - } - - fun invokeServerMethod(methodName: String, args: List, result: Result) { - try { - val res: SignalRFuture = hub.invoke(Any::class.java, methodName, *args.toTypedArray()) - - res.done { msg: Any? -> - Handler(Looper.getMainLooper()).post { - result.success(msg) - } - } - - res.onError { throwable -> - Handler(Looper.getMainLooper()).post { - result.error("Error", throwable.localizedMessage, null) - } - } - } catch (ex: Exception) { - result.error("Error", ex.localizedMessage, null) - } - } -} \ No newline at end of file diff --git a/android/src/main/kotlin/dev/asdevs/signalr_flutter/SignalRFlutterPlugin.kt b/android/src/main/kotlin/dev/asdevs/signalr_flutter/SignalRFlutterPlugin.kt index e0c9a2d..83aaf3f 100644 --- a/android/src/main/kotlin/dev/asdevs/signalr_flutter/SignalRFlutterPlugin.kt +++ b/android/src/main/kotlin/dev/asdevs/signalr_flutter/SignalRFlutterPlugin.kt @@ -1,84 +1,197 @@ package dev.asdevs.signalr_flutter -import androidx.annotation.NonNull; +import android.os.Handler +import android.os.Looper import io.flutter.embedding.engine.plugins.FlutterPlugin -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result -import io.flutter.plugin.common.PluginRegistry.Registrar - -/** SignalRFlutterPlugin */ -public class SignalRFlutterPlugin : FlutterPlugin, MethodCallHandler { - override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { - channel = MethodChannel(flutterPluginBinding.binaryMessenger, "signalR") - channel.setMethodCallHandler(this); +import microsoft.aspnet.signalr.client.ConnectionState +import microsoft.aspnet.signalr.client.Credentials +import microsoft.aspnet.signalr.client.LogLevel +import microsoft.aspnet.signalr.client.SignalRFuture +import microsoft.aspnet.signalr.client.hubs.HubConnection +import microsoft.aspnet.signalr.client.hubs.HubProxy +import microsoft.aspnet.signalr.client.transport.LongPollingTransport +import microsoft.aspnet.signalr.client.transport.ServerSentEventsTransport +import java.lang.Exception + +/** SignalrFlutterPlugin */ +class SignalrFlutterPlugin : FlutterPlugin, SignalrApi.SignalRHostApi { + private lateinit var connection: HubConnection + private lateinit var hub: HubProxy + + private lateinit var signalrApi: SignalrApi.SignalRPlatformApi + + override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + SignalrApi.SignalRHostApi.setup(flutterPluginBinding.binaryMessenger, this) + signalrApi = SignalrApi.SignalRPlatformApi(flutterPluginBinding.binaryMessenger) } - // This static function is optional and equivalent to onAttachedToEngine. It supports the old - // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting - // plugin registration via this function while apps migrate to use the new Android APIs - // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. - // - // It is encouraged to share logic between onAttachedToEngine and registerWith to keep - // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called - // depending on the user's project. onAttachedToEngine or registerWith must both be defined - // in the same class. - companion object { - lateinit var channel: MethodChannel - - @JvmStatic - fun registerWith(registrar: Registrar) { - val channel = MethodChannel(registrar.messenger(), "signalR") - channel.setMethodCallHandler(SignalRFlutterPlugin()) - } + override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { + SignalrApi.SignalRHostApi.setup(binding.binaryMessenger, null) } - override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { - when (call.method) { - CallMethod.ConnectToServer.value -> { - val arguments = call.arguments as Map<*, *> - @Suppress("UNCHECKED_CAST") - SignalR.connectToServer( - arguments["baseUrl"] as String, - arguments["hubName"] as String, - arguments["queryString"] as String, - arguments["headers"] as? Map ?: emptyMap(), - arguments["transport"] as Int, - arguments["hubMethods"] as? List ?: emptyList(), - result) + override fun connect( + connectionOptions: SignalrApi.ConnectionOptions, + result: SignalrApi.Result? + ) { + try { + connection = + if (connectionOptions.queryString?.isNotEmpty() == true) { + HubConnection( + connectionOptions.baseUrl, + connectionOptions.queryString, + true + ) { _: String, _: LogLevel -> + } + } else { + HubConnection(connectionOptions.baseUrl) + } + + if (connectionOptions.headers?.isNotEmpty() == true) { + val cred = Credentials { request -> + request.headers = connectionOptions.headers + } + connection.credentials = cred + } + + hub = connection.createHubProxy(connectionOptions.hubName) + + connectionOptions.hubMethods?.forEach { methodName -> + hub.on(methodName, { res -> + Handler(Looper.getMainLooper()).post { + signalrApi.onNewMessage(methodName, res) { } + } + }, String::class.java) } - CallMethod.Reconnect.value -> { - SignalR.reconnect(result) + + connection.connected { + Handler(Looper.getMainLooper()).post { + val statusChangeResult = SignalrApi.StatusChangeResult() + statusChangeResult.connectionId = connection.connectionId + statusChangeResult.status = SignalrApi.ConnectionStatus.CONNECTED + signalrApi.onStatusChange(statusChangeResult) { } + } } - CallMethod.Stop.value -> { - SignalR.stop(result) + + connection.reconnected { + Handler(Looper.getMainLooper()).post { + val statusChangeResult = SignalrApi.StatusChangeResult() + statusChangeResult.connectionId = connection.connectionId + statusChangeResult.status = SignalrApi.ConnectionStatus.CONNECTED + signalrApi.onStatusChange(statusChangeResult) { } + } } - CallMethod.IsConnected.value -> { - SignalR.isConnected(result) + + connection.reconnecting { + Handler(Looper.getMainLooper()).post { + val statusChangeResult = SignalrApi.StatusChangeResult() + statusChangeResult.connectionId = connection.connectionId + statusChangeResult.status = SignalrApi.ConnectionStatus.RECONNECTING + signalrApi.onStatusChange(statusChangeResult) { } + } } - CallMethod.ListenToHubMethod.value -> { - if (call.arguments is String) { - val methodName = call.arguments as String - SignalR.listenToHubMethod(methodName, result) - } else { - result.error("Error", "Cast to String Failed", "") + + connection.closed { + Handler(Looper.getMainLooper()).post { + val statusChangeResult = SignalrApi.StatusChangeResult() + statusChangeResult.connectionId = connection.connectionId + statusChangeResult.status = SignalrApi.ConnectionStatus.DISCONNECTED + signalrApi.onStatusChange(statusChangeResult) { } + } + } + + connection.connectionSlow { + Handler(Looper.getMainLooper()).post { + val statusChangeResult = SignalrApi.StatusChangeResult() + statusChangeResult.connectionId = connection.connectionId + statusChangeResult.status = SignalrApi.ConnectionStatus.CONNECTION_SLOW + signalrApi.onStatusChange(statusChangeResult) { } } } - CallMethod.InvokeServerMethod.value -> { - val arguments = call.arguments as Map<*, *> - @Suppress("UNCHECKED_CAST") - SignalR.invokeServerMethod(arguments["methodName"] as String, arguments["arguments"] as? List - ?: emptyList(), result) + + connection.error { handler -> + Handler(Looper.getMainLooper()).post { + val statusChangeResult = SignalrApi.StatusChangeResult() + statusChangeResult.status = SignalrApi.ConnectionStatus.CONNECTION_ERROR + statusChangeResult.errorMessage = handler.localizedMessage + signalrApi.onStatusChange(statusChangeResult) { } + } + } + + when (connectionOptions.transport) { + SignalrApi.Transport.SERVER_SENT_EVENTS -> connection.start( + ServerSentEventsTransport( + connection.logger + ) + ) + SignalrApi.Transport.LONG_POLLING -> connection.start( + LongPollingTransport( + connection.logger + ) + ) + else -> { + connection.start() + } } - else -> { - result.notImplemented() + + result?.success(connection.connectionId ?: "") + } catch (ex: Exception) { + result?.error(ex) + } + } + + override fun reconnect(result: SignalrApi.Result?) { + try { + connection.start() + result?.success(connection.connectionId ?: "") + } catch (ex: Exception) { + result?.error(ex) + } + } + + override fun stop(result: SignalrApi.Result?) { + try { + connection.stop() + } catch (ex: Exception) { + result?.error(ex) + } + } + + override fun isConnected(result: SignalrApi.Result?) { + try { + if (this::connection.isInitialized) { + when (connection.state) { + ConnectionState.Connected -> result?.success(true) + else -> result?.success(false) + } + } else { + result?.success(false) } + } catch (ex: Exception) { + result?.error(ex) } } - override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { - channel.setMethodCallHandler(null) + override fun invokeMethod( + methodName: String, + arguments: MutableList, + result: SignalrApi.Result? + ) { + try { + val res: SignalRFuture = + hub.invoke(String::class.java, methodName, *arguments.toTypedArray()) + + res.done { msg: String? -> + Handler(Looper.getMainLooper()).post { + result?.success(msg ?: "") + } + } + + res.onError { throwable -> + throw throwable + } + } catch (ex: Exception) { + result?.error(ex) + } } } diff --git a/example/.gitignore b/example/.gitignore index f3c2053..0fa6b67 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -40,5 +40,7 @@ app.*.symbols # Obfuscation related app.*.map.json -# Exceptions to above rules. -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/example/.metadata b/example/.metadata index bcef94e..a5584fc 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: bbfbf1770cca2da7c82e887e4e4af910034800b6 + revision: 18116933e77adc82f80866c928266a5b4f1ed645 channel: stable project_type: app diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/android/.gitignore b/example/android/.gitignore index 0a741cb..6f56801 100644 --- a/example/android/.gitignore +++ b/example/android/.gitignore @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 5f102f2..4c53d6c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,21 +26,26 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 33 - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } - lintOptions { - disable 'InvalidPackage' + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "dev.asdevs.signalr_flutter_example" minSdkVersion 16 - targetSdkVersion 30 + targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } @@ -50,16 +55,6 @@ android { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug - - // Enables code shrinking, obfuscation, and optimization for only - // your project's release build type. - minifyEnabled true - - // Enables resource shrinking, which is performed by the - // Android Gradle plugin. - shrinkResources true - - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } diff --git a/example/android/app/proguard-rules.pro b/example/android/app/proguard-rules.pro deleted file mode 100644 index a8f1b9c..0000000 --- a/example/android/app/proguard-rules.pro +++ /dev/null @@ -1 +0,0 @@ --keep class microsoft.aspnet.signalr.client.hubs.** { *; } \ No newline at end of file diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index 0c2eac9..2018986 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -4,6 +4,4 @@ to allow setting breakpoints, to provide hot reload, etc. --> - - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index c5ea17c..6ce41a8 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,13 +1,6 @@ - - - + android:windowSoftInputMode="adjustResize" + android:exported="true"> + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 1f83a33..d74aa35 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ - - diff --git a/example/android/build.gradle b/example/android/build.gradle index 7d84ac3..484f201 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.4.32' + ext.kotlin_version = '1.7.20' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.3' + classpath 'com.android.tools.build:gradle:7.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,15 +14,13 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { project.evaluationDependsOn(':app') } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 38c8d45..94adc3a 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index cef35c9..cc5527d 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Oct 25 12:57:53 IST 2020 +#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/example/ios/.gitignore b/example/ios/.gitignore index e96ef60..7a7f987 100644 --- a/example/ios/.gitignore +++ b/example/ios/.gitignore @@ -1,3 +1,4 @@ +**/dgph *.mode1v3 *.mode2v3 *.moved-aside @@ -18,6 +19,7 @@ Flutter/App.framework Flutter/Flutter.framework Flutter/Flutter.podspec Flutter/Generated.xcconfig +Flutter/ephemeral/ Flutter/app.flx Flutter/app.zip Flutter/flutter_assets/ diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable App CFBundleIdentifier @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 11.0 diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index e8efba1..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1,2 +1,2 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 399e934..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1,2 +1,2 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile index 1e8c3c9..88359b2 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index c99bbf0..311ea70 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -14,9 +14,9 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/signalr_flutter/ios" SPEC CHECKSUMS: - Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c - signalr_flutter: f36ec358cbff2fdaacb27af943c011bfe40a0d91 + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + signalr_flutter: fcbc21129947f1f53e38b6b035012aa150359bc8 -PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c +PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.3 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index d21dd30..8dfc5ac 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ @@ -13,7 +13,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - FD0F2CB55E2A25CAA98D33D6 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 609533FF5E5D2CFB1FE21663 /* Pods_Runner.framework */; }; + A3825B7D4C39CB585CB06C32 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5528DD5FB2E517FAFE0629F /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -30,14 +30,14 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 00D58DCEF6AB359E49B0A5E5 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 5B76B73BD5D07FF9308F297B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - 609533FF5E5D2CFB1FE21663 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 83DF5C9EB55097741FFB02F8 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -45,8 +45,8 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D1B1A99BDBF85886F32A08E8 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - E5C22E8675909FF9B20E40A1 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + D695C71FA7896E0D227EF338 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + E5528DD5FB2E517FAFE0629F /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,19 +54,21 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - FD0F2CB55E2A25CAA98D33D6 /* Pods_Runner.framework in Frameworks */, + A3825B7D4C39CB585CB06C32 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 04622851B8DFB09904D1E061 /* Frameworks */ = { + 961B3FAB7B6342EBA7854FB5 /* Pods */ = { isa = PBXGroup; children = ( - 609533FF5E5D2CFB1FE21663 /* Pods_Runner.framework */, + 00D58DCEF6AB359E49B0A5E5 /* Pods-Runner.debug.xcconfig */, + 83DF5C9EB55097741FFB02F8 /* Pods-Runner.release.xcconfig */, + D695C71FA7896E0D227EF338 /* Pods-Runner.profile.xcconfig */, ); - name = Frameworks; + path = Pods; sourceTree = ""; }; 9740EEB11CF90186004384FC /* Flutter */ = { @@ -86,8 +88,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, - B9B7859EF07F81E35E3C8CE9 /* Pods */, - 04622851B8DFB09904D1E061 /* Frameworks */, + 961B3FAB7B6342EBA7854FB5 /* Pods */, + A09C56985D20AF6CBF21338F /* Frameworks */, ); sourceTree = ""; }; @@ -114,14 +116,12 @@ path = Runner; sourceTree = ""; }; - B9B7859EF07F81E35E3C8CE9 /* Pods */ = { + A09C56985D20AF6CBF21338F /* Frameworks */ = { isa = PBXGroup; children = ( - E5C22E8675909FF9B20E40A1 /* Pods-Runner.debug.xcconfig */, - D1B1A99BDBF85886F32A08E8 /* Pods-Runner.release.xcconfig */, - 5B76B73BD5D07FF9308F297B /* Pods-Runner.profile.xcconfig */, + E5528DD5FB2E517FAFE0629F /* Pods_Runner.framework */, ); - path = Pods; + name = Frameworks; sourceTree = ""; }; /* End PBXGroup section */ @@ -131,14 +131,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 94D27F8F07B537E17CED0C16 /* [CP] Check Pods Manifest.lock */, + 14480EB777FC38A538FB5EB0 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - B334E2AA1444B93C79556562 /* [CP] Embed Pods Frameworks */, + 5247C24FE5952D486D984070 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -197,21 +197,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Thin Binary"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; - }; - 94D27F8F07B537E17CED0C16 /* [CP] Check Pods Manifest.lock */ = { + 14480EB777FC38A538FB5EB0 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -233,21 +219,21 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 9740EEB61CF901F6004384FC /* Run Script */ = { + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Run Script"; + name = "Thin Binary"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n"; }; - B334E2AA1444B93C79556562 /* [CP] Embed Pods Frameworks */ = { + 5247C24FE5952D486D984070 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -264,6 +250,20 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -321,6 +321,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -339,7 +340,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -357,19 +358,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = Y334H564QX; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); PRODUCT_BUNDLE_IDENTIFIER = dev.asdevs.signalrFlutterExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -401,6 +394,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -425,7 +419,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -456,6 +450,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -474,7 +469,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -494,19 +489,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = Y334H564QX; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); PRODUCT_BUNDLE_IDENTIFIER = dev.asdevs.signalrFlutterExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -525,19 +512,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = Y334H564QX; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); PRODUCT_BUNDLE_IDENTIFIER = dev.asdevs.signalrFlutterExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..c87d15a 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ - - - - + + - - UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/example/lib/main.dart b/example/lib/main.dart index 22850c3..4b61303 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,21 +1,25 @@ +// ignore_for_file: avoid_print + import 'package:flutter/material.dart'; import 'dart:async'; + +import 'package:signalr_flutter/signalr_api.dart'; import 'package:signalr_flutter/signalr_flutter.dart'; void main() { - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { - String _signalRStatus = 'Unknown'; + String signalRStatus = "disconnected"; late SignalR signalR; - final GlobalKey rootScaffoldMessengerKey = - GlobalKey(); @override void initState() { @@ -26,41 +30,43 @@ class _MyAppState extends State { // Platform messages are asynchronous, so we initialize in an async method. Future initPlatformState() async { signalR = SignalR( - '', - "", - hubMethods: [""], - statusChangeCallback: _onStatusChange, - hubCallback: _onNewMessage); + "", + "", + hubMethods: [""], + statusChangeCallback: _onStatusChange, + hubCallback: _onNewMessage, + ); } @override Widget build(BuildContext context) { return MaterialApp( - scaffoldMessengerKey: rootScaffoldMessengerKey, home: Scaffold( appBar: AppBar( - title: const Text('SignalR Plugin Example App'), + title: const Text("SignalR Plugin Example App"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('Connection Status: $_signalRStatus\n', - style: Theme.of(context).textTheme.headline5), + Text("Connection Status: $signalRStatus\n", + style: Theme.of(context).textTheme.headline6), Padding( padding: const EdgeInsets.only(top: 20.0), child: ElevatedButton( - onPressed: _buttonTapped, child: Text("Invoke Method")), + onPressed: _buttonTapped, + child: const Text("Invoke Method")), ) ], ), ), floatingActionButton: FloatingActionButton( - child: Icon(Icons.cast_connected), + child: const Icon(Icons.cast_connected), onPressed: () async { - final isConnected = await signalR.isConnected ?? false; + final isConnected = await signalR.isConnected(); if (!isConnected) { - await signalR.connect(); + final connId = await signalR.connect(); + print("Connection ID: $connId"); } else { signalR.stop(); } @@ -70,24 +76,25 @@ class _MyAppState extends State { ); } - _onStatusChange(dynamic status) { + void _onStatusChange(ConnectionStatus? status) { if (mounted) { setState(() { - _signalRStatus = status as String; + signalRStatus = status?.name ?? ConnectionStatus.disconnected.name; }); } } - _onNewMessage(String? methodName, dynamic message) { - print('MethodName = $methodName, Message = $message'); + void _onNewMessage(String methodName, String message) { + print("MethodName = $methodName, Message = $message"); } - _buttonTapped() async { - final res = await signalR.invokeMethod("", - arguments: [""]).catchError((error) { - print(error.toString()); - }); - final snackBar = SnackBar(content: Text('SignalR Method Response: $res')); - rootScaffoldMessengerKey.currentState!.showSnackBar(snackBar); + void _buttonTapped() async { + try { + final result = await signalR.invokeMethod("", + arguments: [""]); + print(result); + } catch (e) { + print(e); + } } } diff --git a/example/pubspec.lock b/example/pubspec.lock index 03530a5..b194746 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,80 +21,94 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.5" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" signalr_flutter: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.1.2" + version: "0.2.0" sky_engine: dependency: transitive description: flutter @@ -106,7 +120,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -127,35 +141,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.0 <3.0.0" flutter: ">=1.20.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d258038..ed3fa06 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,13 +1,20 @@ name: signalr_flutter_example description: Demonstrates how to use the signalr_flutter plugin. +version: 1.0.0+1 # The following line prevents the package from being accidentally published to -# pub.dev using `pub publish`. This is preferred for private packages. +# pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter @@ -22,12 +29,19 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 + cupertino_icons: ^1.0.5 dev_dependencies: flutter_test: sdk: flutter + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.1 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 3e324eb..4a9d8c3 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -13,13 +13,13 @@ import 'package:signalr_flutter_example/main.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), + (Widget widget) => + widget is Text && widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/ios/.gitignore b/ios/.gitignore index aa479fd..0c88507 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -34,4 +34,5 @@ Icon? .tags* /Flutter/Generated.xcconfig +/Flutter/ephemeral/ /Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/ios/Assets/SwiftR.js b/ios/Assets/SwiftR.js old mode 100755 new mode 100644 index ef9ac77..cb4c719 --- a/ios/Assets/SwiftR.js +++ b/ios/Assets/SwiftR.js @@ -1,118 +1,118 @@ window.swiftR = { - connection: null, - hubs: {}, - transport: 'auto', - headers: {}, - messages: {} + connection: null, + hubs: {}, + transport: ['webSockets','serverSentEvents','longPolling'], + headers: {}, + messages: {} }; -$(function() { - $.ajaxSetup({ - beforeSend: function (jqxhr) { - for (var h in swiftR.headers) { - jqxhr.setRequestHeader(h, swiftR.headers[h]); - } - } - }); - postMessage({ message: 'ready' }); +$(function () { + $.ajaxSetup({ + beforeSend: function (jqxhr) { + for (var h in swiftR.headers) { + jqxhr.setRequestHeader(h, swiftR.headers[h]); + } + } + }); + postMessage({ message: 'ready' }); }); function initialize(baseUrl, isHub) { - swiftR.connection = isHub ? $.hubConnection(baseUrl) : $.connection(baseUrl); - var connection = swiftR.connection; - - connection.logging = true; - - if (!isHub) { - connection.received(function(data) { - postMessage({ data: data }); - }); - } - - connection.starting(function() { - postMessage({ message: 'starting' }); - }); - - connection.connectionSlow(function() { - postMessage({ message: 'connectionSlow' }); - }); - - connection.reconnecting(function() { - postMessage({ message: 'reconnecting' }); - }); - - connection.reconnected(function() { - postMessage({ message: 'reconnected' }); - }); - - connection.disconnected(function () { - postMessage({ message: 'disconnected' }); - }); - - connection.error(function(error) { - postMessage({ message: 'error', error: processError(error) }); - }); + swiftR.connection = isHub ? $.hubConnection(baseUrl) : $.connection(baseUrl); + var connection = swiftR.connection; + + connection.logging = true; + + if (!isHub) { + connection.received(function (data) { + postMessage({ data: data }); + }); + } + + connection.starting(function () { + postMessage({ message: 'starting' }); + }); + + connection.connectionSlow(function () { + postMessage({ message: 'connectionSlow' }); + }); + + connection.reconnecting(function () { + postMessage({ message: 'reconnecting' }); + }); + + connection.reconnected(function () { + postMessage({ message: 'reconnected' }); + }); + + connection.disconnected(function () { + postMessage({ message: 'disconnected' }); + }); + + connection.error(function (error) { + postMessage({ message: 'error', error: processError(error) }); + }); } function start() { - swiftR.connection.start({ transport: swiftR.transport }).done(function() { - postMessage({ message: 'connected', connectionId: swiftR.connection.id }); - }).fail(function() { - postMessage({ message: 'connectionFailed' }); - }); + swiftR.connection.start({ transport: swiftR.transport }).done(function () { + postMessage({ message: 'connected', connectionId: swiftR.connection.id }); + }).fail(function () { + postMessage({ message: 'connectionFailed' }); + }); } function addHandler(id, hubName, method) { - var hub = ensureHub(hubName); - - hub.on(method, function() { - postMessage({ - id: id, - hub: hub.hubName, - method: method, - arguments: [].slice.call(arguments) + var hub = ensureHub(hubName); + + hub.on(method, function () { + postMessage({ + id: id, + hub: hub.hubName, + method: method, + arguments: [].slice.call(arguments) + }); }); - }); } function postMessage(msg) { - var id = Math.random().toString(36).slice(2, 10); - swiftR.messages[id] = msg; - - if (window.webkit) { - webkit.messageHandlers.interOp.postMessage(id); - } else { - var frame = $('