@@ -698,36 +698,37 @@ public void onReceive(Context context, Intent intent) {
698
698
699
699
}
700
700
} else if (RNFetchBlobService .RNFetchBlobServiceBroadcast .equals (action )) {
701
- if (intent .hasCategory (RNFetchBlobService .CategoryProgress )) {
702
- HashMap map = (HashMap )intent .getSerializableExtra (RNFetchBlobService .BroadcastProgressMap );
703
- String taskId = (String )map .get (RNFetchBlobService .KeyTaskId );
704
- WritableMap args = Arguments .createMap ();
705
- args .putString ("taskId" , taskId );
706
- args .putString ("written" , String .valueOf (map .get (RNFetchBlobService .KeyWritten )));
707
- args .putString ("total" , String .valueOf (map .get (RNFetchBlobService .KeyTotal )));
708
-
709
- // emit event to js context
710
- RNFetchBlob .RCTContext .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
711
- .emit (RNFetchBlobConst .EVENT_UPLOAD_PROGRESS , args );
712
- } else if (intent .hasCategory (RNFetchBlobService .CategorySuccess )) {
713
- // Could be fail.
714
- try {
715
- byte [] bytes = intent .getByteArrayExtra (RNFetchBlobService .BroadcastMsg );
716
- callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_UTF8 , new String (bytes , "UTF-8" ));
717
- } catch (IOException e ) {
718
- callback .invoke ("RNFetchBlob failed to encode response data to UTF8 string." , null );
719
- } finally {
720
- // lets unregister.
701
+ String _taskId = intent .getStringExtra (RNFetchBlobService .BroadcastTaskId );
702
+ if (this .taskId .equals (_taskId )) {
703
+ if (intent .hasCategory (RNFetchBlobService .CategoryProgress )) {
704
+ HashMap map = (HashMap ) intent .getSerializableExtra (RNFetchBlobService .BroadcastProgressMap );
705
+
706
+ WritableMap args = Arguments .createMap ();
707
+ args .putString ("taskId" , _taskId );
708
+ args .putString ("written" , String .valueOf (map .get (RNFetchBlobService .KeyWritten )));
709
+ args .putString ("total" , String .valueOf (map .get (RNFetchBlobService .KeyTotal )));
710
+
711
+ // emit event to js context
712
+ RNFetchBlob .RCTContext .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
713
+ .emit (RNFetchBlobConst .EVENT_UPLOAD_PROGRESS , args );
714
+ } else if (intent .hasCategory (RNFetchBlobService .CategorySuccess )) {
715
+ // Could be fail.
716
+ try {
717
+ byte [] bytes = intent .getByteArrayExtra (RNFetchBlobService .BroadcastMsg );
718
+ callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_UTF8 , new String (bytes , "UTF-8" ));
719
+ } catch (IOException e ) {
720
+ callback .invoke ("RNFetchBlob failed to encode response data to UTF8 string." , null );
721
+ } finally {
722
+ // lets unregister.
723
+ Context appCtx = RNFetchBlob .RCTContext .getApplicationContext ();
724
+ appCtx .unregisterReceiver (this );
725
+ }
726
+ } else if (intent .hasCategory (RNFetchBlobService .CategoryFail )) {
727
+ callback .invoke ("Request failed." , null , null );
721
728
Context appCtx = RNFetchBlob .RCTContext .getApplicationContext ();
722
729
appCtx .unregisterReceiver (this );
723
730
}
724
- } else if (intent .hasCategory (RNFetchBlobService .CategoryFail )) {
725
- callback .invoke ("Request failed." , null , null );
726
- Context appCtx = RNFetchBlob .RCTContext .getApplicationContext ();
727
- appCtx .unregisterReceiver (this );
728
731
}
729
732
}
730
733
}
731
-
732
-
733
734
}
0 commit comments