@@ -488,6 +488,12 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
488488
489489 if ([param[@" type" ] isEqual: @" single" ] && param[@" username" ] != nil ) {
490490 JMSGImageContent *content = [[JMSGImageContent alloc ] initWithImageData: [NSData dataWithContentsOfFile: mediaPath]];
491+
492+ content.uploadHandler = ^(float percent, NSString *msgID) {
493+ [self .bridge.eventDispatcher sendAppEventWithName: uploadProgressEvent body: @{@" messageId" : msgID,
494+ @" progress" : @(percent)}];
495+ };
496+
491497 JMSGMessage *message = [JMSGMessage createSingleMessageWithContent: content username: param[@" username" ]];
492498 if (param[@" extras" ] && [param[@" extras" ] isKindOfClass: [NSDictionary class ]]) {
493499 NSDictionary *extras = param[@" extras" ];
@@ -513,6 +519,13 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
513519
514520 } else if ([param[@" type" ] isEqual: @" group" ] && param[@" groupId" ] != nil ) {
515521 JMSGImageContent *content = [[JMSGImageContent alloc ] initWithImageData: [NSData dataWithContentsOfFile: mediaPath]];
522+
523+ content.uploadHandler = ^(float percent, NSString *msgID) {
524+
525+ [self .bridge.eventDispatcher sendAppEventWithName: uploadProgressEvent body: @{@" messageId" : msgID,
526+ @" progress" : @(percent)}];
527+ };
528+
516529 JMSGMessage *message = [JMSGMessage createGroupMessageWithContent: content groupId: param[@" groupId" ]];
517530 if (param[@" extras" ] && [param[@" extras" ] isKindOfClass: [NSDictionary class ]]) {
518531 NSDictionary *extras = param[@" extras" ];
@@ -794,6 +807,12 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
794807 if ([param[@" type" ] isEqual: @" single" ] && param[@" username" ] != nil ) {
795808 // send single text message
796809 JMSGFileContent *content = [[JMSGFileContent alloc ] initWithFileData: [NSData dataWithContentsOfFile: mediaPath] fileName: fileName];
810+
811+ content.uploadHandler = ^(float percent, NSString *msgID) {
812+ [self .bridge.eventDispatcher sendAppEventWithName: uploadProgressEvent body: @{@" messageId" : msgID,
813+ @" progress" : @(percent)}];
814+ };
815+
797816 JMSGMessage *message = [JMSGMessage createSingleMessageWithContent: content username: param[@" username" ]];
798817 if (param[@" extras" ] && [param[@" extras" ] isKindOfClass: [NSDictionary class ]]) {
799818 NSDictionary *extras = param[@" extras" ];
@@ -818,6 +837,12 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
818837 if ([param[@" type" ] isEqual: @" group" ] && param[@" groupId" ] != nil ) {
819838 // send group text message
820839 JMSGFileContent *content = [[JMSGFileContent alloc ] initWithFileData: [NSData dataWithContentsOfFile: mediaPath] fileName: fileName];
840+
841+ content.uploadHandler = ^(float percent, NSString *msgID) {
842+ [self .bridge.eventDispatcher sendAppEventWithName: uploadProgressEvent body: @{@" messageId" : msgID,
843+ @" progress" : @(percent)}];
844+ };
845+
821846 JMSGMessage *message = [JMSGMessage createGroupMessageWithContent: content groupId: param[@" groupId" ]];
822847 if (param[@" extras" ] && [param[@" extras" ] isKindOfClass: [NSDictionary class ]]) {
823848 NSDictionary *extras = param[@" extras" ];
0 commit comments