迁移到 App Center SDK 4.0.0 及更高版本

重要

Visual Studio App Center 计划于 2025 年 3 月 31 日停用。 虽然可以继续使用 Visual Studio App Center,直到它完全停用,但你可以考虑迁移到几个建议的替代方法。

详细了解支持时间线和替代方案。

为了避免与 Apple 专用框架中的类发生命名冲突,SDK 现在使用 MSAC 前缀而不是 MS 更改 SDK API。

Swift API 现在具有更 快速的 样式,所有类都应使用无前缀,例如 AppCenter。 函数和属性命名也根据 Apple Swift 最佳做法进行了更改。

更新 App Center SDK

首先,使用其中一个依赖项管理器更新 App Center SDK。

API 的使用

更新 App Center SDK API 最快且最方便的方法是使用自动更正。 更换后,应得到如下所示的结果。

将 App Center SDK 更新到 4.0.0 及更高版本之前。

[MSAppCenter start:@"{Your App Secret}" withServices:@[[MSAnalytics class], [MSCrashes class]]];
MSAppCenter.start("{Your App Secret}", withServices: [MSAnalytics.self, MSCrashes.self])

将 App Center SDK 更新到 4.0.0 及更高版本后。

[MSACAppCenter start:@"{Your App Secret}" withServices:@[[MSACAnalytics class], [MSACCrashes class]]];
AppCenter.start(withAppSecret: "{Your App Secret}", services: [Analytics.self, Crashes.self])

此外,getter [MSACWrapperCrashesHelper getCrashHandlerSetupDelegate] 现已弃用,请改用 [MSACWrapperCrashesHelper crashHandlerSetupDelegate]

下表显示了已重命名的 API。

App Center Core 较低 4.0.0 App Center Core 4.0.0+ (ObjC) App Center Core 4.0.0+ (Swift)
MSAppCenter MSACAppCenter AppCenter
MSLogLevel MSACLogLevel LogLevel
MSLogLevelVerbose MSACLogLevelVerbose LogLevel.verbose
MSLogLevelWarning MSACLogLevelWarning 。警告
MSLogLevelInfo MSACLogLevelInfo 。信息
MSLogLevelAssert MSACLogLevelAssert 。断言
MSLogHandler MSACLogHandler LogHandler
MSLogMessageProvider MSACLogMessageProvider LogMessageProvider
App Center Analytics 较低 4.0.0 App Center Analytics 4.0.0+ (ObjC) App Center Alanlytics 4.0.0+ (Swift)
MSAnalytics MSACAnalytics 分析
MSFlags MSACFlags Flags
MSFlagsNormal MSACFlagsNormal Flags.normal
MSFlagsCritical MSACFlagsCritical 。关键
MSFlagsDefault MSACFlagsDefault 。默认
MSEventProperties MSACEventProperties EventProperties
App Center 崩溃较低 4.0.0 App Center 崩溃 4.0.0+ (ObjC) App Center 崩溃 4.0.0+ (Swift)
MS 崩溃 MSAC 崩溃 崩溃
MSCrashesDelegate MSACCrashesDelegate CrashesDelegate
MSErrorReport MSACErrorReport ErrorReport
MSErrorAttachmentLog MSACErrorAttachmentLog ErrorAttachmentLog
MSUserConfirmationDontSend MSACUserConfirmationDontSend UserConfirmation.dontSend
MSUserConfirmationSend MSACUserConfirmationSend 。发送
MSUserConfirmationAlways MSACUserConfirmationAlways 。总是
MSUserConfirmationHandler MSACUserConfirmationHandler UserConfirmationHandler
App Center 分发较低 4.0.0 App Center 分发 4.0.0+ (ObjC) App Center 分发 4.0.0+ (Swift)
MSDistribute MSACDistribute 分发
MSDistributeDelegate MSACDistributeDelegate DistributeDelegate
MSCrashHandlerSetupDelegate MSACCrashHandlerSetupDelegate CrashHandlerSetupDelegate
MSReleaseDetails MSACReleaseDetails ReleaseDetails
MSUpdateAction MSACUpdateAction UpdateAction
MSUpdateActionUpdate MSACUpdateActionUpdate UpdateAction.update
MSUpdateActionPostpone MSACUpdateActionPostpone 。推迟
MSUpdateTrack MSACUpdateTrack UpdateTrack
MSUpdateTrackPublic MSACUpdateTrackPublic UpdateTrack.public
MSUpdateTrackPrivate MSACUpdateTrackPrivate 。私人

Swift API 更改

App Center Core 下部 4.0.0 App Center Core 4.0.0+
MSAppCenter.isEnabled () AppCenter.enabled
MSAppCenter.setEnabled (true) AppCenter.enabled = true
MSAppCenter.isConfigured () AppCenter.isConfigured
MSAppCenter.isRunningInAppCenterTestCloud () AppCenter.isRunningInAppCenterTestCloud
MSAppCenter.isAppDelegateForwarderEnabled () AppCenter.isAppDelegateForwarderEnabled
MSAppCenter.installId () AppCenter.installId
MSAppCenter.isDebuggerAttached () AppCenter.isDebuggerAttached
MSAppCenter.sdkVersion () AppCenter.sdkVersion
MSAppCenter.setLogUrl (“{Log Url}”) AppCenter.logUrl = “{Log Url}”
MSAppCenter.setLogLevel (.verbose) AppCenter.logLevel = .verbose
MSAppCenter.setLogHandler (logHandler) AppCenter.logHandler = logHandler
MSAppCenter.SetUserId (“{User Id}”) AppCenter.userId = “{User Id}”
MSAppCenter.setCountryCode (“{Country Code}”) AppCenter.countryCode = “{Country Code}”
MSAppCenter.setAppSecret (“{App Secret}”) AppCenter.appSecret = “{App Secret}”
MSAppCenter.setString (“value”, forKey: “key”) AppCenter.setString (“value”,用于:“key”)
MSServiceAbstract.isAppSecretRequired () ServiceAbstract.isAppSecretRequired
MSAppCenter.addChannelUnitWithConfiguration (配置) AppCenter.addChannelUnit (withConfiguration:configuration)
MSAppCenter.configureWithAppSecret (“{App Secret}”) AppCenter.configure (withAppSecret:“{App Secret}”)
MSAppCenter.start (“{App Secret}”,withServices: [MSAnalytics.self]) AppCenter.start (,带有AppSecret:“{App Secret}”,服务:[Analytics.self])
MSAppCenter.startWithServices ([MSAnalytics.self, MSCrashes.self]) AppCenter.start (服务:[Analytics.self, Crashes.self])
MSAppCenter.startFromLibraryWithServices ([MSAnalytics.self]) AppCenter.startFromLibrary (服务:[Analytics.self]) “)
App Center Analytics 较低 4.0.0 App Center Analytics 4.0.0+
MSAnalytics.isEnabled () Analytics.enabled
MSAnalytics.setEnabled (true) Analytics.enabled = true
MSAnalytics.setTransmissionInterval (600) Analytics.transmissionInterval = 600
App Center 崩溃较低 4.0.0 App Center 崩溃 4.0.0+
MSCrashes.isEnabled () Crashes.enabled
MSCrashes.setEnabled (true) Crashes.enabled = true
MSCrashes.setDelegate (委托) Crashes.delegate = delegate
MSCrashes.hasCrashedInLastSession () Crashes.hasCrashedInLastSession
MSCrashes.hasReceivedMemoryWarningInLastSession () Crashes.hasReceivedMemoryWarningInLastSession
MSErrorReport.isAppKill () ErrorReport.isAppKill
MSCrashes.lastSessionCrashReport () Crashes.lastSessionCrashReport
MSCrashes.setAutomaticProcessing (true) Crashes.automaticProcessing = true
MSWrapperCrashesHelper.getCrashHandlerSetupDelegate WrapperCrashesHelper.crashHandlerSetupDelegate
MSWrapperCrashesHelper.setCrashHandlerSetupDelegate (委托) WrapperCrashesHelper.crashHandlerSetupDelegate = delegate
MSCrashes.setUserConfirmationHandler (处理程序) Crashes.userConfirmationHandler = handler
App Center Distribute lower 4.0.0 App Center Distribute 4.0.0+
MSDistribute.isEnabled () Distribute.enabled
MSDistribute.setEnabled (true) Distribute.enabled = true
MSDistribute.setDelegate (委托) Distribute.delegate = delegate
MSDistribute.setApiUrl (“{API URL}”) Distribute.apiUrl = “{API URL}”
MSDistribute.setInstallUrl (“{Install URL}”) Distribute.installUrl = “{Instal URL}”
MSDistribute.isMandatoryUpdate Distribute.mandatoryUpdate

CrashesDelegate 更改

将 App Center SDK 更新到 4.0.0 及更高版本之前。

func crashes(_ crashes: MSCrashes!, shouldProcessErrorReport errorReport: MSErrorReport!) -> Bool

func crashes(_ crashes: MSCrashes!, willSend errorReport: MSErrorReport!)

func crashes(_ crashes: MSCrashes!, didSucceedSending errorReport: MSErrorReport!)

func crashes(_ crashes: MSCrashes!, didFailSending errorReport: MSErrorReport!, withError error: Error!)

func attachments(with crashes: MSCrashes, for errorReport: MSErrorReport) -> [MSErrorAttachmentLog]

将 App Center SDK 更新到 4.0.0 及更高版本后。

func crashes(_ crashes: Crashes, shouldProcess errorReport: ErrorReport) -> Bool

func crashes(_ crashes: Crashes, willSend errorReport: ErrorReport)

func crashes(_ crashes: Crashes, didSucceedSending errorReport: ErrorReport)

func crashes(_ crashes: Crashes, didFailSending errorReport: ErrorReport, withError error: Error)

func attachments(with crashes: Crashes, for errorReport: ErrorReport) -> [ErrorAttachmentLog]

DistributeDelegate 更改

将 App Center SDK 更新到 4.0.0 及更高版本之前。

func distribute(_ distribute: MSDistribute!, releaseAvailableWith details: MSReleaseDetails!) -> Bool

将 App Center SDK 更新到 4.0.0 及更高版本后。

  func distribute(_ distribute: Distribute, releaseAvailableWith details: ReleaseDetails) -> Bool