다음을 통해 공유


App Center 충돌(tvOS)

중요

Visual Studio App Center는 2025년 3월 31일에 사용 중지될 예정입니다. Visual Studio App Center가 완전히 사용 중지될 때까지 계속 사용할 수 있지만 마이그레이션을 고려할 수 있는 몇 가지 권장 대안이 있습니다.

지원 타임라인 및 대안에 대해 자세히 알아보세요.

App Center 충돌은 앱이 충돌할 때마다 자동으로 크래시 로그를 생성합니다. 로그는 먼저 디바이스의 스토리지에 기록되며 사용자가 앱을 다시 시작하면 크래시 보고서가 App Center로 전송됩니다. 크래시 수집은 베타 및 라이브 앱( 즉, App Store 제출된 앱 모두에 적용됩니다. 크래시 로그에는 크래시 해결에 도움이 되는 중요한 정보가 포함되어 있습니다.

애플리케이션에서 SDK를 아직 설정하지 않은 경우 시작 섹션을 따릅니다.

또한 tvOS의 충돌 로그에는 앱에 대한 기호를 제공하는 방법을 설명하는 App Center 진단 설명서를 검사 심볼레이션이 필요합니다.

참고

제대로 기호화된 스택 추적을 받으려면 비트 코드가 사용하지 않도록 설정되어 있는지 확인합니다. App Center의 iOS 기호화 설명서에서 비트코드에 대해 자세히 알아볼 수 있습니다.

참고

4.0.0 App Center 버전에서는 호환성이 손상되는 변경 내용이 도입되었습니다. App Center SDK 4.0.0 이상으로 마이그레이션 섹션에 따라 이전 버전에서 App Center를 마이그레이션합니다.

테스트 크래시 생성

App Center Crashs는 SDK를 쉽게 테스트하기 위한 테스트 크래시를 생성하는 API를 제공합니다. 이 API는 테스트/베타 앱에서만 사용할 수 있으며 프로덕션 앱에서는 아무 작업도 수행하지 않습니다.

[MSACCrashes generateTestCrash];
Crashes.generateTestCrash()

이전 충돌에 대한 자세한 정보 가져오기

App Center Crashs에는 앱이 충돌하는 경우 더 많은 정보를 제공하는 두 개의 API가 있습니다.

앱이 이전 세션에서 메모리 부족 경고를 받았나요?

SDK를 시작한 후 언제든지 앱이 이전 세션에서 메모리 경고를 받았는지 검사 수 있습니다.

[MSACCrashes hasReceivedMemoryWarningInLastSession];
Crashes.hasReceivedMemoryWarningInLastSession

참고

이 메서드는 가 시작된 후에 Crashes 만 사용해야 하며, 항상 또는 시작 전에 반환 NOfalse 됩니다.

참고

경우에 따라 메모리가 낮은 디바이스는 이벤트를 보낼 수 없습니다.

이전 세션에서 앱이 충돌했나요?

SDK를 시작한 후 언제든지 이전 실행에서 앱이 충돌했는지 검사 수 있습니다.

[MSACCrashes hasCrashedInLastSession];
Crashes.hasCrashedInLastSession

이는 크래시가 발생한 후 앱의 동작 또는 UI를 조정하려는 경우에 유용합니다.

참고

이 메서드는 가 시작된 후에 MSACCrashes 만 사용해야 하며, 항상 또는 시작 전에 반환 NOfalse 됩니다.

마지막 충돌에 대한 세부 정보

앱이 이전에 충돌한 경우 마지막 크래시에 대한 세부 정보를 얻을 수 있습니다.

MSACErrorReport *crashReport = [MSACCrashes lastSessionCrashReport];
var crashReport = Crashes.lastSessionCrashReport

참고

이 메서드는 가 시작된 후에 Crashes 만 사용해야 하며, 시작 전에 항상 반환 nil 됩니다.

이 API에는 다양한 사용 사례가 있으며, 가장 일반적인 경우는 이 API를 호출하고 사용자 지정 CrashesDelegate를 구현하는 사용자입니다.

App Center 크래시 사용 사용자 지정

App Center 충돌은 개발자가 App Center에 크래시 로그를 보내기 전과 전송할 때 추가 작업을 수행할 수 있는 콜백을 제공합니다.

사용자 지정 동작을 추가하려면 -protocol을 CrashesDelegate채택해야 합니다. 모든 메서드는 선택 사항입니다.

대리자로 등록

[MSACCrashes setDelegate:self];
Crashes.delegate = self

참고

App Center가 시작 직후 크래시 처리를 시작하므로 를 호출AppCenter.start하기 전에 대리자를 설정해야 합니다.

크래시가 처리되어야 하나요?

crashes:shouldProcessErrorReport:특정 크래시가 처리되어야 하는지 여부를 결정하려는 경우 -protocol을 채택CrashesDelegate하는 클래스에서 -method를 구현합니다. 예를 들어 무시하려는 시스템 수준 크래시가 있을 수 있으며 App Center로 보내지 않을 수 있습니다.

- (BOOL)crashes:(MSACCrashes *)crashes shouldProcessErrorReport:(MSACErrorReport *)errorReport {
  return YES; // return YES if the crash report should be processed, otherwise NO.
}
func crashes(_ crashes: Crashes, shouldProcess errorReport: ErrorReport) -> Bool {
  return true; // return true if the crash report should be processed, otherwise false.
}

처리된 오류

App Center를 사용하면 메서드를 통해 trackError 처리된 예외를 사용하여 오류를 추적할 수도 있습니다. 앱은 필요에 따라 속성 또는/및 첨부 파일을 처리된 오류 보고서에 첨부하여 추가 컨텍스트를 제공할 수 있습니다.

@try {
  // Throw error.
} @catch (NSError *error) {

  // Init attachments.
  NSArray<MSACErrorAttachmentLog *> attachments = @[ MSACErrorAttachmentLog attachmentWithText:@"Hello world!" filename:@"hello.txt"] ]

  // Init properties.
  NSDictionary *properties = @{ "Category" : "Music", "Wifi" : "On" };

  // Track errors.
  [MSACCrashes trackError:error withProperties:properties attachments:attachments];
  [MSACCrashes trackError:error withProperties:properties attachments:nil];
  [MSACCrashes trackError:error withProperties:nil attachments:attachments];
  [MSACCrashes trackError:error withProperties:nil attachments:nil];
}
do {
  // Throw error.
} catch {

  // Init attachments.
  let attachments = [ErrorAttachmentLog.attachment(withText: "Hello world!", filename: "hello.txt")]

  // Init properties.
  let properties:Dictionary<String, String> = ["Category" : "Music", "Wifi" : "On"]

  // Track errors.
  Crashes.trackError(error, properties: properties, attachments: attachments)
  Crashes.trackError(error, properties: properties, attachments: nil)
  Crashes.trackError(error, properties: nil, attachments: attachments)
  Crashes.trackError(error, properties: nil, attachments: nil)
}

예외 추적의 경우 메서드를 사용할 trackException 수 있습니다.

@try {
  // Throw exceptions.
} @catch (NSException *exception) {

  // Init exceptions.
  MSACExceptionModel *customException1 = [MSACExceptionModel initWithType:@"Custom exception" exceptionMessage:"Track custom exception.", stackTrace:exception.callStackSymbols];
  MSACExceptionModel *customException2 = [MSACExceptionModel initWithException:exception];

  // Track exceptions.
  [MSACCrashes trackException:customException1 withProperties:properties attachments:nil];
  [MSACCrashes trackException:customException2 withProperties:properties attachments:nil];
}
do {
  // Throw exception.
} catch {

  // Init exception.
  let exception = ExceptionModel(withType: "Custom exception", exceptionMessage: "Track custom exception.", stackTrace: Thread.callStackSymbols)

  // Track exception.
  Crashes.trackException(exception, properties: properties, attachments: nil)
}

사용자 개인 정보 보호가 중요한 경우 App Center에 크래시 보고서를 보내기 전에 사용자의 확인을 받을 수 있습니다. SDK는 충돌 보고서를 보내기 전에 사용자의 확인을 기다리도록 App Center 크래시를 알리는 콜백을 노출합니다.

이렇게 하기로 선택한 경우, 예를 들어 대화 상자 프롬프트를 통해 항상 보내기, 보내기 및보내지 않음 옵션 중 하나를 통해 사용자의 확인을 받을 책임이 있습니다. 입력에 따라 App Center에 수행할 작업을 알려 주며 그에 따라 크래시가 처리됩니다.

참고

SDK는 이에 대한 대화 상자를 표시하지 않습니다. 앱은 사용자 동의를 요청하기 위해 자체 UI를 제공해야 합니다.

참고

앱이 사용자 확인 대화 상자를 구현하지 않는 경우 명시적으로 를 호출 notifyWithUserConfirmation 하면 안 됩니다. 크래시 모듈은 로그 전송을 암시적으로 처리합니다.

다음 메서드는 사용자 확인 처리기를 설정하는 방법을 보여줍니다.

[MSACCrashes setUserConfirmationHandler:(^(NSArray<MSACErrorReport *> *errorReports) {

  // Your code to present your UI to the user, e.g. an UIAlertController.
  UIAlertController *alertController = [UIAlertController
      alertControllerWithTitle:@"Sorry about that!"
                      message:@"Do you want to send an anonymous crash report so we can fix the issue?"
                preferredStyle:UIAlertControllerStyleAlert];

  [alertController
      addAction:[UIAlertAction actionWithTitle:@"Don't send"
                                        style:UIAlertActionStyleCancel
                                      handler:^(UIAlertAction *action) {
                                        [MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationDontSend];
                                      }]];

  [alertController
      addAction:[UIAlertAction actionWithTitle:@"Send"
                                        style:UIAlertActionStyleDefault
                                      handler:^(UIAlertAction *action) {
                                        [MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationSend];
                                      }]];

  [alertController
      addAction:[UIAlertAction actionWithTitle:@"Always send"
                                        style:UIAlertActionStyleDefault
                                      handler:^(UIAlertAction *action) {
                                        [MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationAlways];
                                      }]];
  // Show the alert controller.
  [self.window.rootViewController presentViewController:alertController animated:YES completion:nil];
  return YES; // Return YES if the SDK should await user confirmation, otherwise NO.
})];
MSACCrashes.setUserConfirmationHandler({ (errorReports: [MSACErrorReport]) in

  // Your code to present your UI to the user, e.g. an UIAlertController.
  let alertController = UIAlertController(title: "Sorry about that!",
                                          message: "Do you want to send an anonymous crash report so we can fix the issue?",
                                          preferredStyle:.alert)

  alertController.addAction(UIAlertAction(title: "Don't send", style: .cancel) {_ in
    MSACCrashes.notify(with: .dontSend)
  })

  alertController.addAction(UIAlertAction(title: "Send", style: .default) {_ in
    MSACCrashes.notify(with: .send)
  })

  alertController.addAction(UIAlertAction(title: "Always send", style: .default) {_ in
    MSACCrashes.notify(with: .always)
  })

  // Show the alert controller.
  self.window?.rootViewController?.present(alertController, animated: true)
  return true // Return true if the SDK should await user confirmation, otherwise return false.
})

위의 처리기 블록에서 반환 YES/true 하는 경우 앱은 다음 API를 사용하여 사용자 권한을 얻고 결과와 함께 SDK에 메시지를 보내야 합니다. 위의 샘플에서와 같이 이에 대한 경고를 사용하는 경우 -callback 구현 alertView:clickedButtonAtIndex:내에서 경고를 호출합니다.

// Depending on the users's choice, call notifyWithUserConfirmation: with the right value.
[MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationDontSend];
[MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationSend];
[MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationAlways];
// Depending on the user's choice, call notify(with:) with the right value.
MSACCrashes.notify(with: .dontSend)
MSACCrashes.notify(with: .send)
MSACCrashes.notify(with: .always)

크래시 로그에 대한 전송 상태 대한 정보 가져오기

때때로 앱 충돌의 상태 알고 싶습니다. 일반적인 사용 사례는 앱이 크래시 보고서를 제출하고 있음을 사용자에게 알리는 UI를 표시하거나, 실행 후 앱이 빠르게 충돌하는 경우 크래시 로그를 제출할 수 있도록 앱의 동작을 조정하려고 할 수 있다는 것입니다. -protocol은 CrashesDelegate앱에서 진행 중인 작업을 알리기 위해 사용할 수 있는 세 가지 콜백을 정의합니다.

SDK가 크래시 로그를 보내기 전에 다음 콜백이 호출됩니다.

- (void)crashes:(MSACCrashes *)crashes willSendErrorReport:(MSACErrorReport *)errorReport {
  // Your code, e.g. to present a custom UI.
}
func crashes(_ crashes: Crashes, willSend errorReport: ErrorReport) {
  // Your code, e.g. to present a custom UI.
}

엔드포인트에 네트워크 문제 또는 중단이 있고 앱을 willSendErrorReport 다시 시작하는 경우 프로세스가 다시 시작되면 가 다시 트리거됩니다.

SDK가 크래시 로그를 성공적으로 보낸 후 다음 콜백이 호출됩니다.

- (void)crashes:(MSACCrashes *)crashes didSucceedSendingErrorReport:(MSACErrorReport *)errorReport {
  // Your code, e.g. to hide the custom UI.
}
func crashes(_ crashes: Crashes, didSucceedSending errorReport: ErrorReport) {
  // Your code goes here.
}

SDK가 크래시 로그를 보내지 못한 경우 다음 콜백이 호출됩니다.

- (void)crashes:(MSACCrashes *)crashes didFailSendingErrorReport:(MSACErrorReport *)errorReport withError:(NSError *)error {
  // Your code goes here.
}
func crashes(_ crashes: Crashes, didFailSending errorReport: ErrorReport, withError error: Error) {
  // Your code goes here.
}

수신은 didFailSendingErrorReport4xx 코드와 같은 복구할 수 없는 오류가 발생했음을 의미합니다. 예를 들어 401 은 가 잘못됨을 appSecret 의미합니다.

이 콜백은 네트워크 문제인 경우 트리거되지 않습니다. 이 경우 SDK는 계속 재시도하고 네트워크 연결이 중단되는 동안 다시 시도를 일시 중지합니다.

크래시 보고서에 첨부 파일 추가

크래시 보고서에 이진 및 텍스트 첨부 파일을 추가할 수 있습니다. SDK는 크래시와 함께 전송되므로 App Center 포털에서 볼 수 있습니다. 다음 콜백은 이전 애플리케이션 시작에서 저장된 크래시 보내기 직전에 호출됩니다. 크래시가 발생할 때 호출되지 않습니다. 다음은 충돌 시 텍스트와 이미지를 연결하는 방법의 예입니다.

- (NSArray<MSACErrorAttachmentLog *> *)attachmentsWithCrashes:(MSACCrashes *)crashes
                                             forErrorReport:(MSACErrorReport *)errorReport {
  MSACErrorAttachmentLog *attachment1 = [MSACErrorAttachmentLog attachmentWithText:@"Hello world!" filename:@"hello.txt"];
  MSACErrorAttachmentLog *attachment2 = [MSACErrorAttachmentLog attachmentWithBinary:[@"Fake image" dataUsingEncoding:NSUTF8StringEncoding] filename:@"fake_image.jpeg" contentType:@"image/jpeg"];
  return @[ attachment1, attachment2 ];
}
func attachments(with crashes: Crashes, for errorReport: ErrorReport) -> [ErrorAttachmentLog]? {
  let attachment1 = ErrorAttachmentLog.attachment(withText: "Hello world!", filename: "hello.txt")
  let attachment2 = ErrorAttachmentLog.attachment(withBinary: "Fake image".data(using: String.Encoding.utf8), filename: nil, contentType: "image/jpeg")
  return [attachment1!, attachment2!]
}

참고

크기 제한은 현재 7MB입니다. 더 큰 첨부 파일을 보내려고 하면 오류가 트리거됩니다.

런타임에 App Center 충돌 사용 또는 사용 안 함

런타임에 App Center 크래시를 사용하거나 사용하지 않도록 설정할 수 있습니다. 사용하지 않도록 설정하면 SDK에서 앱에 대한 크래시 보고를 수행하지 않습니다.

[MSACCrashes setEnabled:NO];
Crashes.enabled = false

App Center 크래시를 다시 사용하도록 설정하려면 동일한 API를 사용하지만 매개 변수로 전달 YES/true 합니다.

[MSACCrashes setEnabled:YES];
Crashes.enabled = true

상태는 애플리케이션이 시작되는 동안 디바이스의 스토리지에 유지됩니다.

참고

이 메서드는 가 시작된 후에 Crashes 만 사용해야 합니다.

App Center 크래시가 사용하도록 설정되어 있는지 확인

App Center 크래시가 사용하도록 설정되어 있는지 여부를 검사 수도 있습니다.

BOOL enabled = [MSACCrashes isEnabled];
var enabled = Crashes.enabled

참고

이 메서드는 가 시작된 후에 Crashes 만 사용해야 하며, 시작 전에 항상 반환 false 됩니다.