728x90
728x170

iOS 에서 api를 호출하는데 앱이 그냥 강제 종료가 되는 이슈가 있어서 확인해 보니

아래와 같은 에러가 발생되었다.

 

System.AggregateException: One or more errors occurred. (The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.) ---> System.Net.Http.HttpRequestException: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. ---> Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLStringKey=http://store261.softp.kr/api/storemaster_list.asp, NSErrorFailingURLKey=http://store261.softp.kr/api/storemaster_list.asp, _NSURLErrorRelatedURLSessionTaskErrorKey=(

    "LocalDataTask <36626D02-EB1C-40C4-A40A-F66913B92860>.<1>"

),

 _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <36626D02-EB1C-40C4-A40A-F66913B92860>.<1>, NSUnderlyingError=0x280e16490 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}}

   --- End of inner exception stack trace ---

  at System.Net.Http.NSUrlSessionHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x001d4] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/Foundation/NSUrlSessionHandler.cs:527

  at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506

   --- End of inner exception stack trace ---

  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTas

kCanceledExceptions) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2029

  at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <3fe48c4c600840c0ba57ff7c65150717>:0

  at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <3fe48c4c600840c0ba57ff7c65150717>:0

  at MemberShip.Helper.GetPostData[T] (System.String url) [0x00011] in <8a457d6bb9d24b0c95cd15e165d4d34f>:0

---> (Inner Exception #0) System.Net.Http.HttpRequestException: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. ---> Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Trans

port Security policy requires the use of a secure connection., NSErrorFailingURLStringKey=http://store261.softp.kr/api/storemaster_list.asp, NSErrorFailingURLKey=http://store261.softp.kr/api/storemaster_list.asp, _NSURLErrorRelatedURLSessionTaskErrorKey=(

    "LocalDataTask <36626D02-EB1C-40C4-A40A-F66913B92860>.<1>"

), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <36626D02-EB1C-40C4-A40A-F66913B92860>.<1>, NSUnderlyingError=0x280e16490 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}}

   --- End of inner exception stack trace ---

  at System.Net.Http.NSUrlSessionHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x001d4] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/Foundation/NSUrlSessionHandler.cs:527

2020-12-16 00:02:48.508 MemberShip.iOS[1478:1643755]

  at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMe

ssage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506 <---

 

 

위 에러의 해결 방법은

Info.plist 파일에 아래 내용을 추가하면된다.

 

 

<key>NSAppTransportSecurity</key>

<dict>

  <key>NSAllowsArbitraryLoads</key>

  <true />

</dict>

 

 

728x90
그리드형
Posted by kjun
,