ios - Image download - NSURLSession received Authentication Challenge -
i'm trying download simple image url http://d1vqbpto5tbbz0.cloudfront.net/blog/wp-content/uploads/2014/08/25215844/ios-logo1.png
this simple url access through browser without login.
i have tried code:
nsurlsessionconfiguration *configuration = [nsurlsessionconfiguration defaultsessionconfiguration]; configuration.timeoutintervalforrequest = timeout; nsurlsession *urlsession = [nsurlsession sessionwithconfiguration:configuration delegate:self delegatequeue:nil]; [[urlsession datataskwithurl:urlimage] resume];
for receiving authentication challenge.
what reason it?
i have gone through stackoverflow , found these links:
in links, there mentioned enter user:password. user name , password, can enter?
you have implement nsurlsessiondelegate
protocol method didreceivechallenge
.
whenever authentication challenge occurs method calls. , have mention trusted server.
- (void)urlsession:(nsurlsession *)session task:(nsurlsessiontask *)task didreceivechallenge:(nsurlauthenticationchallenge *)challenge completionhandler:(void (^)(nsurlsessionauthchallengedisposition disposition, nsurlcredential *credential))completionhandler { completionhandler(nsurlsessionauthchallengeusecredential, [nsurlcredential credentialfortrust:challenge.protectionspace.servertrust]); }
Comments
Post a Comment