@@ -29,6 +29,7 @@ library;
2929import 'dart:async' ;
3030import 'dart:isolate' ;
3131
32+ import 'package:logging/logging.dart' ;
3233import 'package:objective_c/objective_c.dart' as objc;
3334
3435import 'native_cupertino_bindings.dart' as ncb;
@@ -54,6 +55,8 @@ export 'native_cupertino_bindings.dart'
5455 NSURLSessionWebSocketCloseCode,
5556 NSURLSessionWebSocketMessageType;
5657
58+ final _logger = Logger ('ClassroomApp' );
59+
5760abstract class _ObjectHolder <T extends objc.NSObject > {
5861 final T _nsObject;
5962
@@ -850,6 +853,28 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
850853 }) {
851854 final protoBuilder = objc.ObjCProtocolBuilder ();
852855
856+ final b =
857+ ncb.ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError
858+ .blocking ((_, nsSession, nsTask, nsError) {
859+ _logger.severe (
860+ 'Complete: session: ${nsSession .ref .pointer } task: ${nsTask .ref .pointer }' );
861+ _decrementTaskCount ();
862+ if (onComplete != null ) {
863+ onComplete (
864+ URLSession ._(nsSession,
865+ isBackground: isBackground, hasDelegate: true ),
866+ URLSessionTask ._(nsTask),
867+ nsError);
868+ }
869+ });
870+
871+ final delegate = objc.getProtocol ('NSURLSessionTaskDelegate' );
872+ final sel = objc.registerName ('URLSession:task:didCompleteWithError:' );
873+ final signature = objc.getProtocolMethodSignature (delegate, sel,
874+ isRequired: false , isInstanceMethod: true )! ;
875+ protoBuilder.implementMethod (sel, signature, b);
876+
877+ /*
853878 ncb.NSURLSessionDataDelegate.URLSession_task_didCompleteWithError_
854879 .implementAsListener(protoBuilder, (nsSession, nsTask, nsError) {
855880 _decrementTaskCount();
@@ -861,7 +886,7 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
861886 nsError);
862887 }
863888 });
864-
889+ */
865890 if (onRedirect != null ) {
866891 ncb
867892 .NSURLSessionDataDelegate
@@ -897,6 +922,9 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
897922 ncb.ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition
898923 .blocking (
899924 (_, nsSession, nsDataTask, nsResponse, nsCompletionHandler) {
925+ _logger.severe (
926+ 'Response: session: ${nsSession .ref .pointer } task: ${nsDataTask .ref .pointer }' );
927+
900928 final exactResponse = URLResponse ._exactURLResponseType (nsResponse);
901929 final disposition = onResponse (
902930 URLSession ._(nsSession,
@@ -929,6 +957,24 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
929957 }
930958
931959 if (onData != null ) {
960+ final b =
961+ ncb.ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData
962+ .blocking ((_, nsSession, nsDataTask, nsData) {
963+ _logger.severe (
964+ 'Data: session: ${nsSession .ref .pointer } task: ${nsDataTask .ref .pointer }' );
965+ onData (
966+ URLSession ._(nsSession,
967+ isBackground: isBackground, hasDelegate: true ),
968+ URLSessionTask ._(nsDataTask),
969+ nsData);
970+ });
971+ final delegate = objc.getProtocol ('NSURLSessionDataDelegate' );
972+ final sel = objc.registerName ('URLSession:dataTask:didReceiveData:' );
973+ final signature = objc.getProtocolMethodSignature (delegate, sel,
974+ isRequired: false , isInstanceMethod: true )! ;
975+ protoBuilder.implementMethod (sel, signature, b);
976+
977+ /*
932978 ncb.NSURLSessionDataDelegate.URLSession_dataTask_didReceiveData_
933979 .implementAsListener(protoBuilder, (nsSession, nsDataTask, nsData) {
934980 onData(
@@ -937,6 +983,7 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
937983 URLSessionTask._(nsDataTask),
938984 nsData);
939985 });
986+ */
940987 }
941988
942989 if (onFinishedDownloading != null ) {
0 commit comments