question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`progress` dose no work in iOS because`setProgress` will call before `sendRequest`

See original GitHub issue

When I fetch a file like that:

FetchBlob
    .fetch('GET','xxx')
    .progress({ interval : 250},(receive,total)=>{
      console.log("progress", receive/total)
    })

I can’t receive progress because progress will be called synchronization with fetch.

In iOS:

  • fetch will call :
RCT_EXPORT_METHOD(fetchBlob:(NSDictionary *)options
                  taskId:(NSString *)taskId
                  method:(NSString *)method
                  url:(NSString *)url
                  headers:(NSDictionary *)headers
                  body:(NSString *)body callback:(RCTResponseSenderBlock)callback)
  • progress will call:
RCT_EXPORT_METHOD(enableProgressReport:(NSString *)taskId interval:(nonnull NSNumber*)interval count:(nonnull NSNumber*)count)

The fetchBlob function will async create an request obj. Before the buildOctetRequest 's onComplete is called ,enableProgressReport has already been called. Caused enableProgressReport can’t find taskID

RCT_EXPORT_METHOD(fetchBlob:(NSDictionary *)options
                  taskId:(NSString *)taskId
                  method:(NSString *)method
                  url:(NSString *)url
                  headers:(NSDictionary *)headers
                  body:(NSString *)body callback:(RCTResponseSenderBlock)callback)
{
    [RNFetchBlobReqBuilder buildOctetRequest:options
                                      taskId:taskId
                                      method:method
                                         url:url
                                     headers:headers
                                        body:body
                                  onComplete:^(NSURLRequest *req, long bodyLength)
    {
        // something went wrong when building the request body
        if(req == nil)
        {
            callback(@[@"RNFetchBlob.fetchBlob failed to create request body"]);
        }
        // send HTTP request
        else
        {
            [[RNFetchBlobNetwork sharedInstance] sendRequest:options
                                               contentLength:bodyLength
                                                      bridge:self.bridge
                                                      taskId:taskId
                                                 withRequest:req
                                                    callback:callback];
        }
    }];
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

13reactions
MJXincommented, Jul 2, 2018

I have to do like this

let fetchobj = FetchBlob.fetch(
      'GET',
      'xxxx'
    )
    
    setTimeout(()=>{
      fetchobj.progress({ interval: 250},(resive,total)=>{
        console.log("progress", resive/total)
      })
    }, 0)

    fetchobj.then((res)=>{
      console.log("res", res)
    })
0reactions
Traviskncommented, Aug 21, 2018

PR is merged

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apple logo with progress bar after updating or restoring ...
When this occurs, the progress bar might be moving very slowly or seem like it isn't moving. Let the device complete the update,...
Read more >
ASIHTTPRequest does not update progress - Stack Overflow
I use ASIHTTPRequest to upload a file of json with encoded image (or [request setFile:imagefile...]), but I cannot update the progress.
Read more >
Troubleshoot OneDrive for iOS app problems - Microsoft Support
Learn how to resolve issues with the OneDrive mobile app.
Read more >
Share your real-time location with others - Google Maps Help
Location Sharing works even when Location History is turned off. ... On your iPhone or iPad, open the Google Maps app Maps ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found