I am trying to receive silent/background push-notifications on an IOS device using Flutter. I have managed to get this to work on Android, Just IOS is the issue.
Setup
- I am using the firebase_messaging 5.1.6 Plugin
- I have ticked remote notifications and background fetch in XCode, and have also enabled Push notifications in Capabilities
- Push notifications with data seem to work fine
My payload (I have tried with and without data)
{"registration_ids":["<IOS DEVICE IDS>"],"priority":"high","content_available":true,"mutable_content":true,"data":{"title":"Title.","body":"Message."}}
My firebase configuration below:
The reason onBackgroundMessage is set to null is that I get the error below:
Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#start on channel plugins.flutter.io/firebase_messaging)
Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async {
// test code
NetworkService networkService = NetworkService();
networkService.getData("test"); // hit a test endpoint to make sure the code excuted
print("myBackgroundMessageHandler: $message");
}
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
NetworkService networkService = NetworkService();
networkService.getData("test");
},
onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler,
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
},
);
Full error
2019-10-15 08:44:52.766262+0100 Runner[16132:1794539] - <AppMeasurement>[I-ACS036001] Analytics screen reporting is disabled. UIViewController transitions will not be logged.
2019-10-15 08:44:52.909787+0100 Runner[16132:1794333] Metal API Validation Enabled
2019-10-15 08:44:53.173885+0100 Runner[16132:1794552] flutter: Observatory listening on http://127.0.0.1:58105/hC1vIwLgB_o=/
2019-10-15 08:44:53.294824+0100 Runner[16132:1794539] 6.9.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60102000 started
2019-10-15 08:44:53.295297+0100 Runner[16132:1794539] 6.9.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see https://help.apple.com/xcode/mac/8.0/#/dev3ec8a1cb4)
2019-10-15 08:44:53.940639+0100 Runner[16132:1794545] flutter: 1 /var/mobile/Containers/Data/Application/E0ADA03B-747D-4A66-9A96-97160F70D80A/Documents/db
2019-10-15 08:44:54.030056+0100 Runner[16132:1794545] [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#start on channel plugins.flutter.io/firebase_messaging)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
<asynchronous suspension>
#1 FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:118:16)
#2 configureFirebaseMessaging (package:gard/utilities/service_locator.dart:53:22)
#3 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#4 configureFirebaseMessaging (package:gard/utilities/service_locator.dart:47:40)
#5 main (package:gard/main.dart:31:9)
#6 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#7 _rootRunUnary (dart:async/zone.dart:1132:38)
#8 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#9 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#10 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#11 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#12 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#13 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#14 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#15 setupDatabase (package:gard/utilities/service_locator.dart)
#16 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#17 _rootRunUnary (dart:async/zone.dart:1132:38)
#18 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#19 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#20 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#21 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#22 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#23 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#24 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#25 DatabaseCreator.initDatabase (package:gard/database/database_creator.dart)
#26 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#27 _rootRunUnary (dart:async/zone.dart:1132:38)
#28 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#29 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#30 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#31 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#32 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#33 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#34 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#35 BasicLock.synchronized (package:synchronized/src/basic_lock.dart)
#36 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#37 _rootRunUnary (dart:async/zone.dart:1132:38)
#38 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#39 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#40 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#41 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#42 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#43 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#44 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#45 ReentrantLock.synchronized.<anonymous closure> (package:synchronized/src/reentrant_lock.dart)
#46 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#47 _rootRunUnary (dart:async/zone.dart:1132:38)
#48 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#49 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#50 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#51 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#52 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#53 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#54 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#55 SqfliteDatabaseFactoryMixin.openDatabase.<anonymous closure> (package:sqflite/src/factory_mixin.dart)
#56 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#57 _rootRunUnary (dart:async/zone.dart:1132:38)
#58 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#59 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#60 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#61 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#62 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#63 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#64 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#65 SqfliteDatabaseOpenHelper.openDatabase (package:sqflite/src/database.dart)
#66 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#67 _rootRunUnary (dart:async/zone.dart:1132:38)
#68 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#69 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#70 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#71 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#72 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#73 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#74 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#75 SqfliteDatabaseMixin.doOpen (package:sqflite/src/database_mixin.dart)
#76 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#77 _rootRunUnary (dart:async/zone.dart:1132:38)
#78 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#79 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#80 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#81 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#82 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#83 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#84 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#85 SqfliteDatabaseMixin.txnSynchronized (package:sqflite/src/database_mixin.dart)
#86 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#87 _rootRunUnary (dart:async/zone.dart:1132:38)
#88 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#89 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#90 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#91 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#92 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#93 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#94 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#95 SqfliteDatabaseMixin._runTransaction (package:sqflite/src/database_mixin.dart)
#96 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#97 _rootRunUnary (dart:async/zone.dart:1132:38)
#98 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#99 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#100 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#101 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#102 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#103 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#104 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#105 SqfliteDatabaseMixin.endTransaction (package:sqflite/src/database_mixin.dart)
#106 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#107 _rootRunUnary (dart:async/zone.dart:1132:38)
#108 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#109 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#110 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#111 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#112 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#113 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#114 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#115 SqfliteDatabaseMixin.txnSynchronized (package:sqflite/src/database_mixin.dart)
#116 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#117 _rootRunUnary (dart:async/zone.dart:1132:38)
#118 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#119 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#120 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#121 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#122 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#123 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#124 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#125 wrapDatabaseException (package:sqflite/src/exception_impl.dart)
#126 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#127 _rootRunUnary (dart:async/zone.dart:1132:38)
#128 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#129 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#130 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#131 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#132 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#133 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#134 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#135 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
#136 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#137 _rootRunUnary (dart:async/zone.dart:1132:38)
#138 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#139 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#140 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#141 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#142 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#143 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#144 _rootRun (dart:async/zone.dart:1124:13)
#145 _CustomZone.run (dart:async/zone.dart:1021:19)
#146 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#147 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#148 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#149 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
2019-10-15 08:44:54.520569+0100 Runner[16132:1794333] [TSBackgroundFetch configure]: {
enableHeadless = 1;
minimumFetchInterval = 15;
stopOnTerminate = 0;
}
2019-10-15 08:44:54.525630+0100 Runner[16132:1794333] [TSBackgroundFetch addListener]: com.transistorsoft/flutter_background_fetch
2019-10-15 08:44:54.525691+0100 Runner[16132:1794333] [TSBackgroundFetch start]
2019-10-15 08:44:54.761953+0100 Runner[16132:1794545] flutter: ---- BackgroundFetch configure success: 2
2019-10-15 08:44:56.139196+0100 Runner[16132:1794545] flutter: -----setNotificationToken-----
2019-10-15 08:44:56.139413+0100 Runner[16132:1794545] flutter: fSpD_VrnO2k:APA91bEwfT083oNVxPDy-kiF9mTPZiyoQbS2owQTK18erSARU8akzANG6H1zWr5bgMpAePkx3jc3F3spSAOSsf4Wr_zj3bDEi1yw1E5UeHSJCsMh3flDxNxq2mE__FwhiP2M35szQi0l
Background message handling is not supported on iOS as of firebase_messaging 6.0.9.
As you can see in the changelog, support was added only for Android: https://pub.dev/packages/firebase_messaging#515
Check out this github issue and add a reaction if you want it implemented sooner: https://github.com/FirebaseExtended/flutterfire/issues/47
The firebase_messaging > 8.0.0-dev plugin now supports background message handling for iOS too.
Changelog: https://pub.dev/packages/firebase_messaging/versions/8.0.0-dev.11/changelog
Migrating to v8:
https://firebase.flutter.dev/docs/migration/
Related
macos version 11.6 flutter_blue version 0.8.0
The device service has been failed to get, but I can get the service normally when I get it on my mobile phone. However, the service is not available on the Mac OS
Error occurred at
var services = device.discoverServices();
2021-11-16 11:32:03.486 flutter_xxxx[43362:321219] uuid: xxxxxx-23e0-4bdc-ac16-xxxxxxxx value: (null)
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FormatException: The format is invalid
#0 Guid._fromString (package:flutter_blue/src/guid.dart:45:7)
#1 new Guid (package:flutter_blue/src/guid.dart:15:39)
#2 new BluetoothCharacteristic.fromProto (package:flutter_blue/src/bluetooth_characteristic.dart:35:27)
#3 new BluetoothService.fromProto.<anonymous closure> (package:flutter_blue/src/bluetooth_service.dart:19:29)
#4 MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#5 ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#6 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#7 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#8 new List.of (dart:core-patch/array_patch.dart:50:28)
#9 ListIterable.toList (dart:_internal/iterable.dart:213:44)
#10 new BluetoothService.fromProto (package:flutter_blue/src/bluetooth_service.dart:20:14)
#11 BluetoothDevice.discoverServices.<anonymous closure>.<anonymous closure> (package:flutter_blue/src/bluetooth_device.dart:67:38)
#12 MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#13 ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#14 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#15 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#16 new List.of (dart:core-patch/array_patch.dart:50:28)
#17 ListIterable.toList (dart:_internal/iterable.dart:213:44)
#18 BluetoothDevice.discoverServices.<anonymous closure> (package:flutter_blue/src/bluetooth_device.dart:67:69)
#19 _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
#20 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#21 _rootRunUnary (dart:async/zone.dart:1436:47)
#22 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#23 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#24 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#25 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#26 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#27 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#28 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#29 _rootRunUnary (dart:async/zone.dart:1436:47)
#30 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#31 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#32 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#33 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#34 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#35 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#36 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#37 _rootRunUnary (dart:async/zone.dart:1436:47)
#38 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#39 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#40 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#41 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#42 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#43 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#44 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#45 _rootRunUnary (dart:async/zone.dart:1436:47)
#46 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#47 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#48 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#49 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#50 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#51 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#52 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#53 _rootRunUnary (dart:async/zone.dart:1436:47)
#54 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#55 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#56 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#57 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#58 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#59 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#60 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#61 _rootRunUnary (dart:async/zone.dart:1436:47)
#62 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#63 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#64 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#65 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#66 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
#67 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
#68 _rootRun (dart:async/zone.dart:1420:47)
#69 _CustomZone.run (dart:async/zone.dart:1328:19)
#70 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#71 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
#72 _rootRun (dart:async/zone.dart:1428:13)
#73 _CustomZone.run (dart:async/zone.dart:1328:19)
#74 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#75 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
#76 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#77 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
Error occurred at
guid.dart
static List<int> _fromString(String input) {
if (input == null) {
throw new ArgumentError("Input was null");
}
input = _removeNonHexCharacters(input);
final bytes = hex.decode(input);
if (bytes.length != 16) {
throw new FormatException("The format is invalid");
}
return bytes;
}
string input is "" error . can you help me analyze why
I noticed that the function onpacket(packet) is used to classify server messages, and has five cases in there. I think only EVENT is a custom message, but I often receive BINARY_EVENT with null data, along with an error. I don't know why. My server is using SpringBoot+netty-socket-io.
The following is the error message.
E/flutter (19571): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: Closure call with mismatched arguments: function 'call'
E/flutter (19571): Receiver: Closure: (String, [dynamic]) => void from Function 'emit':.
E/flutter (19571): Tried calling: call()
E/flutter (19571): Found: call(String, [dynamic]) => void
E/flutter (19571): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (19571): #1 Function._apply (dart:core-patch/function_patch.dart:12:68)
E/flutter (19571): #2 Function.apply (dart:core-patch/function_patch.dart:33:12)
E/flutter (19571): #3 Socket.onevent (package:socket_io_client/src/socket.dart:278:18)
E/flutter (19571): #4 Socket.onpacket (package:socket_io_client/src/socket.dart:238:9)
E/flutter (19571): #5 EventEmitter.emit. (package:socket_io_common/src/util/event_emitter.dart:52:14)
E/flutter (19571): #6 List.forEach (dart:core-patch/growable_array.dart:282:8)
E/flutter (19571): #7 EventEmitter.emit (package:socket_io_common/src/util/event_emitter.dart:51:11)
E/flutter (19571): #8 Manager.ondecoded (package:socket_io_client/src/manager.dart:320:5)
E/flutter (19571): #9 EventEmitter.emit. (package:socket_io_common/src/util/event_emitter.dart:52:14)
E/flutter (19571): #10 List.forEach (dart:core-patch/growable_array.dart:282:8)
E/flutter (19571): #11 EventEmitter.emit (package:socket_io_common/src/util/event_emitter.dart:51:11)
E/flutter (19571): #12 Decoder.add (package:socket_io_common/src/parser/parser.dart:173:16)
E/flutter (19571): #13 Manager.ondata (package:socket_io_client/src/manager.dart:311:13)
E/flutter (19571): #14 EventEmitter.emit. (package:socket_io_common/src/util/event_emitter.dart:52:14)
E/flutter (19571): #15 List.forEach (dart:core-patch/growable_array.dart:282:8)
E/flutter (19571): #16 EventEmitter.emit (package:socket_io_common/src/util/event_emitter.dart:51:11)
E/flutter (19571): #17 Socket.onPacket (package:socket_io_client/src/engine/socket.dart:467:11)
E/flutter (19571): #18 Socket.setTransport. (package:socket_io_client/src/engine/socket.dart:292:34)
E/flutter (19571): #19 EventEmitter.emit. (package:socket_io_common/src/util/event_emitter.dart:52:14)
E/flutter (19571): #20 List.forEach (dart:core-patch/growable_array.dart:282:8)
E/flutter (19571): #21 EventEmitter.emit (package:socket_io_common/src/util/event_emitter.dart:51:11)
E/flutter (19571): #22 Transport.onPacket (package:socket_io_client/src/engine/transport/transport.dart:128:5)
E/flutter (19571): #23 Transport.onData (package:socket_io_client/src/engine/transport/transport.dart:122:5)
E/flutter (19571): #24 IOWebSocketTransport.addEventListeners. (package:socket_io_client/src/engine/transport/io_websocket_transport.dart:67:7)
E/flutter (19571): #25 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (19571): #26 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (19571): #27 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (19571): #28 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (19571): #29 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (19571): #30 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:779:19)
E/flutter (19571): #31 _StreamController._add (dart:async/stream_controller.dart:655:7)
E/flutter (19571): #32 _StreamController.add (dart:async/stream_controller.dart:597:5)
E/flutter (19571): #33 new _WebSocketImpl._fromSocket. (dart:_http/websocket_impl.dart:1146:21)
E/flutter (19571): #34 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (19571): #35 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (19571): #36 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (19571): #37 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (19571): #38 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (19571): #39 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:70:11)
E/flutter (19571): #40 _EventSinkWrapper.add (dart:async/stream_transformers.dart:17:11)
E/flutter (19571): #41 _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:341:22)
E/flutter (19571): #42 _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:233:46)
E/flutter (19571): #43 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:122:24)
E/flutter (19571): #44 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (19571): #45 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (19571): #46 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (19571): #47 _BufferingSt
I am trying to decode messages from netty server and I'm not entirely sure if the data decoded is decoded properly. Do I need to do anything with the dart socket to make it work with the protobuf message being sent from netty? Do I also need to do anything before writing any message? Also do I keep parsing on every time it receives data or when it calls onDone?
Socket.connect(ip, port).then((Socket sock) {
print("Connected");
socket = sock;
socket.setOption(SocketOption.tcpNoDelay, true);
socket.listen(onReceive,
onError: (e) {
print('Server error: $e');
},
onDone: onDoneEvent,
cancelOnError: false);
});
The server channel handlers:
p.addLast(new ProtobufVarint32FrameDecoder());
p.addLast(new MultiplePacketDecoder(decoders));
p.addLast(new ProtobufVarint32LengthFieldPrepender());
p.addLast(new ProtobufEncoder());
p.addLast(processingHandler);
Edit
Oh and by the way, whenever I try to parse the message, I get this error
E/flutter (25389): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
E/flutter (25389): #0 CodedBufferReader.readTag (package:protobuf/src/protobuf/coded_buffer_reader.dart:144:7)
E/flutter (25389): #1 _mergeFromCodedBufferReader (package:protobuf/src/protobuf/coded_buffer.dart:34:21)
E/flutter (25389): #2 GeneratedMessage.mergeFromBuffer (package:protobuf/src/protobuf/generated_message.dart:173:5)
E/flutter (25389 My class): #3 PacketHandler.parseFromBytes (package:chatclientflutter/backend/packethandler.dart:32:26)
E/flutter (25389 My class): #4 Client.onDoneEvent (package:chatclientflutter/backend/client.dart:77:46)
E/flutter (25389): #5 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (25389): #6 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (25389): #7 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (25389): #8 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
E/flutter (25389): #9 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
E/flutter (25389): #10 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
E/flutter (25389): #11 _SyncStreamController._sendDone (dart:async/stream_controller.dart:772:19)
E/flutter (25389): #12 _StreamController._closeUnchecked (dart:async/stream_controller.dart:629:7)
E/flutter (25389): #13 _StreamController.close (dart:async/stream_controller.dart:622:5)
E/flutter (25389): #14 _Socket._onData (dart:io-patch/socket_patch.dart:1781:21)
E/flutter (25389): #15 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (25389): #16 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (25389): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (25389): #18 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (25389): #19 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
E/flutter (25389): #20 _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)
E/flutter (25389): #21 _StreamController._add (dart:async/stream_controller.dart:640:7)
E/flutter (25389): #22 _StreamController.add (dart:async/stream_controller.dart:586:5)
E/flutter (25389): #23 new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1330:35)
E/flutter (25389): #24 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:837:18)
E/flutter (25389): #25 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (25389): #26 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
Please review your headers, if your header contains 'Sec-WebSocket-Extensions': 'permessage-deflate; client_max_window_bits'. It doesn't work.
When I cancel image gallery picker my flutter debugger suddenly crashes with such log. This is not possible to continue debugging.
Is it possible to skip this? Or this is just a temporary bug?
Unhandled exception:
NoSuchMethodError: The getter 'className' was called on null.
Receiver: null
Tried calling: className
#0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1 serializeProcedure (package:front_end/src/fasta/kernel/utils.dart:99:29)
#2 FrontendCompiler.compileExpression (package:vm/frontend_server.dart:482:16)
<asynchronous suspension>
#3 _FlutterFrontendCompiler.compileExpression (package:frontend_server/server.dart:62:22)
#4 listenAndCompile.<anonymous closure> (package:vm/frontend_server.dart:797:20)
<asynchronous suspension>
#5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#8 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#9 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#10 _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#11 _LineSplitterSink._addLines (dart:convert/line_splitter.dart:154:13)
#12 _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:129:5)
#13 StringConversionSinkMixin.add (dart:convert/string_conversion.dart:189:5)
#14 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#15 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#16 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#17 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#18 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#19 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#20 _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#21 _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273:7)
#22 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348:20)
#23 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:341:5)
#24 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
#25 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#26 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#27 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#28 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#29 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#30 _StreamController._add (dart:async/stream_controller.dart:639:7)
#31 _StreamController.add (dart:async/stream_controller.dart:585:5)
#32 _Socket._onData (dart:io/runtime/binsocket_patch.dart:1721:41)
#33 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#34 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#35 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#36 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#37 _StreamController._add (dart:async/stream_controller.dart:639:7)
#38 _StreamController.add (dart:async/stream_controller.dart:585:5)
#39 new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1283:33)
#40 _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:826:14)
#41 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#42 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#43 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#44 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
Unhandled exception:
SocketException: Write failed (OS Error: Broken pipe, errno = 32), port = 0
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#4 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
This is the code I use
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
You are canceling the picker so it returns null as expected. You should handle it.
You have also the file_picker plugin that includes image picker and also has the options to pick other file formats, if you want.
I upgraded to AngularDart 0.13.0 and I am receiving the errors below. What is the correct way to initialize the RoutingModule with the new di package 2.0.1?
In main.dart I have:
class RoutingModule extends Module {
RoutingModule() {
bind(RouteInitializerFn, toValue: myRouteInitializer);
bind(NgRoutingUsePushState,
toFactory: (_) => new NgRoutingUsePushState.value(false));
}
}
Let me know if you think any other Modules would be relevant. The rest are just simple bind(Component); statements.
I am receiving the following 2 errors:
bind(RouteProvider): Inject list without toFactory is deprecated. Use `toInstanceOf: Type|Key` instead. Called from:
#0 Binding.bind (package:di/src/module.dart:33:11)
#1 DirectiveInjector.bind (package:angular/core_dom/directive_injector.dart:163:23)
#2 module (package:angular/routing/ng_view.dart:60:21)
#3 ElementBinder.bind (package:angular/core_dom/element_binder.dart:285:35)
#4 TaggingViewFactory._bindTagged (package:angular/core_dom/tagging_view_factory.dart:95:36)
#5 TaggingViewFactory._link (package:angular/core_dom/tagging_view_factory.dart:143:24)
#6 TaggingViewFactory.call (package:angular/core_dom/tagging_view_factory.dart:72:12)
#7 Application.run.<anonymous closure>.<anonymous closure> (package:angular/application.dart:183:22)
#8 _rootRunUnary (dart:async/zone.dart:730)
#9 _ZoneDelegate.runUnary (dart:async/zone.dart:462)
#10 _onRunUnary.<anonymous closure> (package:angular/core/zone.dart:116:63)
#11 VmTurnZone._onRunBase (package:angular/core/zone.dart:99:16)
#12 _onRunUnary (package:angular/core/zone.dart:116:17)
#13 _ZoneDelegate.runUnary (dart:async/zone.dart:462)
#14 _CustomizedZone.runUnary (dart:async/zone.dart:667)
#15 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:488)
#16 _Future._propagateToListeners (dart:async/future_impl.dart:571)
#17 _Future._completeWithValue (dart:async/future_impl.dart:331)
#18 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:393)
#19 _rootRun (dart:async/zone.dart:723)
#20 _ZoneDelegate.run (dart:async/zone.dart:453)
#21 _onScheduleMicrotask.<anonymous closure> (package:angular/core/zone.dart:119:43)
#22 VmTurnZone._finishTurn (package:angular/core/zone.dart:146:34)
#23 VmTurnZone._onRunBase (package:angular/core/zone.dart:106:43)
#24 _onRun (package:angular/core/zone.dart:112:17)
#25 _ZoneDelegate.run (dart:async/zone.dart:453)
#26 _CustomizedZone.run (dart:async/zone.dart:663)
#27 VmTurnZone.run (package:angular/core/zone.dart:235:40)
#28 Application.run (package:angular/application.dart:171:20)
#29 main (http://localhost/main.dart:52:11)
Closure call with mismatched arguments: function 'RoutingModule.RoutingModule.<anonymous closure>'
NoSuchMethodError: incorrect number of arguments passed to method named 'RoutingModule.RoutingModule.<anonymous closure>'
Receiver: Closure: (dynamic) => dynamic
Tried calling: RoutingModule.RoutingModule.<anonymous closure>()
Found: RoutingModule.RoutingModule.<anonymous closure>(_#0x14ac1f93)
STACKTRACE:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1 ModuleInjector.getByKey (package:di/src/injector.dart:162:48)
#2 ModuleInjector.getByKey (package:di/src/injector.dart:185:7)
#3 ModuleInjector.getByKey (package:di/src/injector.dart:145:38)
#4 ModuleInjector.getByKey (package:di/src/injector.dart:185:7)
#5 DirectiveInjector._getByKey (package:angular/core_dom/directive_injector.dart:209:72)
#6 DirectiveInjector._new (package:angular/core_dom/directive_injector.dart:287:39)
#7 DirectiveInjector._getDirectiveByKey (package:angular/core_dom/directive_injector.dart:216:94)
#8 DirectiveInjector._getByKey (package:angular/core_dom/directive_injector.dart:211:44)
#9 DirectiveInjector.getByKey (package:angular/core_dom/directive_injector.dart:198:23)
#10 DirectiveInjector.getByKey (package:angular/core_dom/directive_injector.dart:199:7)
#11 DirectiveInjector.getByKey (package:angular/core_dom/directive_injector.dart:199:7)
#12 ElementBinder._link (package:angular/core_dom/element_binder.dart:207:49)
#13 ElementBinder.bind (package:angular/core_dom/element_binder.dart:298:10)
#14 TaggingViewFactory._bindTagged (package:angular/core_dom/tagging_view_factory.dart:95:36)
#15 TaggingViewFactory._link (package:angular/core_dom/tagging_view_factory.dart:143:24)
#16 TaggingViewFactory.call (package:angular/core_dom/tagging_view_factory.dart:72:12)
#17 TaggingViewFactory.call (package:angular/core_dom/tagging_view_factory.dart:74:7)
#18 TaggingViewFactory.call (package:angular/core_dom/tagging_view_factory.dart:74:7)
#19 Application.run.<anonymous closure>.<anonymous closure> (package:angular/application.dart:183:22)
#20 _rootRunUnary (dart:async/zone.dart:730)
#21 _ZoneDelegate.runUnary (dart:async/zone.dart:462)
#22 _onRunUnary.<anonymous closure> (package:angular/core/zone.dart:116:63)
#23 VmTurnZone._onRunBase (package:angular/core/zone.dart:99:16)
#24 _onRunUnary (package:angular/core/zone.dart:116:17)
#25 _ZoneDelegate.runUnary (dart:async/zone.dart:462)
#26 _CustomizedZone.runUnary (dart:async/zone.dart:667)
#27 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:488)
#28 _Future._propagateToListeners (dart:async/future_impl.dart:571)
#29 _Future._completeWithValue (dart:async/future_impl.dart:331)
#30 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:393)
#31 _rootRun (dart:async/zone.dart:723)
#32 _ZoneDelegate.run (dart:async/zone.dart:453)
#33 _onScheduleMicrotask.<anonymous closure> (package:angular/core/zone.dart:119:43)
#34 VmTurnZone._finishTurn (package:angular/core/zone.dart:146:34)
#35 VmTurnZone._onRunBase (package:angular/core/zone.dart:106:43)
#36 _onRun (package:angular/core/zone.dart:112:17)
#37 _ZoneDelegate.run (dart:async/zone.dart:453)
#38 _CustomizedZone.run (dart:async/zone.dart:663)
#39 VmTurnZone.run (package:angular/core/zone.dart:235:40)
#40 Application.run (package:angular/application.dart:171:20)
#41 main (http://localhost/main.dart:52:11)
EDIT:
I changed my main function to:
void main() {
applicationFactory()
.run();
}
and I am still getting the bind(RouteProvider) error.
The Closure call with mismatched arguments error goes away if I comment out the bind(NgRoutingUsePushState, ...) line.
Inject list without toFactory is deprecated. Use toInstanceOf: Type|Key instead
I guess toInstanceOf isn't appropriate because it takes a type instead of an instance. I would try toValue instead of toFactory
For the mismatched arguments error, you have to remove the _ parameter in the anonymous func:
bind(NgRoutingUsePushState, toFactory: () => new NgRoutingUsePushState.value(false));
I'm still investigating the other issue, which I also have. I'll let you know when I find it.