遷移至 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) |
---|---|---|
MSCrashes | 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”, for: “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}”, services: [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 = 委派 |
MSCrashes.hasCrashedInLastSession () | Crashes.hasCrashedInLastSession |
MSCrashes.hasReceivedMemoryWarningInLastSession () | Crashes.hasReceivedMemoryWarningInLastSession |
MSErrorReport.isAppKill () | ErrorReport.isAppKill |
MSCrashes.lastSessionCrashReport () | Crashes.lastSessionCrashReport |
MSCrashes.setAutomaticProcessing (true) | Crashes.automaticProcessing = true |
MSWrapperCrashesHelper.getCrashHandlerSetupDelegate | Wrapper CrashHelper.crashHandlerSetupDelegate |
MSWrapperCrashesHelper.setCrashHandlerSetupDelegate (委派) | Wrapper CrashHelper.crashHandlerSetupDelegate = delegate |
MSCrashes.setUserConfirmationHandler (處理程式) | Crashes.userConfirmationHandler = handler |
App Center 發佈較低 4.0.0 |
App Center 散發 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