Pada Firebase iOS SDK untuk Swift versi 4.0.0, kami menyertakan perubahan untuk mengikuti konvensi penamaan dalam Pedoman Desain Swift API. Untuk memperbaiki error atau peringatan yang mungkin Anda terima saat mengupdate versi Firebase iOS SDK aplikasi, ikuti langkah-langkah dalam panduan migrasi ini.
Perubahan dalam versi baru
Perubahan berikut telah dilakukan pada Swift SDK di semua produk Firebase:
- Menghapus awalan
FIR
di seluruh nama untuk semua konstanta, protokol, class, enum, dan definisi jenis. - Mengganti nama
FIRApp
menjadiFirebaseApp
. - Mengganti nama
FIROptions
menjadiFirebaseOptions
.
Untuk mengetahui daftar lengkap perubahan, lihat bagian daftar perubahan mendetail.
Mengatasi error
Cara terbaik untuk mengatasi error yang dihasilkan dari perubahan ini adalah dengan menggunakan dialog Fix-it di Xcode.
- Saat Anda membuka project yang telah diperbarui di ruang kerja Xcode, error yang dihasilkan dari perubahan penamaan akan muncul di navigator masalah.
- Klik error tersebut dan atasi dengan saran di Dialog Fix-it.
Mengatasi konflik penamaan
Untuk mengatasi konflik penamaan, gunakan namespace yang disediakan oleh modul. Misalnya,
dalam kasus FIRUser
, yang sekarang menjadi User
, Anda dapat membedakan antara class/struct User
dan class User
Firebase.
@import Firebase ... var firebaseUser: Firebase.User?
Daftar perubahan mendetail
Analytics
Sebelumnya | Baru |
---|---|
Functions | |
FIRAnalytics | |
logEvent(withName:parameters:) |
logEvent(_:parameters:) |
Penggunaan sebelumnya:
FIRAnalytics.logEvent(withName: "com.myapp.appStart", parameters: nil)Penggunaan baru: Analytics.logEvent("com.myapp.appStart", parameters: nil) | |
setUserPropertyString(_:forName:) | setUserProperty(_:forName:) |
Penggunaan sebelumnya:
FIRAnalytics.setUserPropertyString("mechanic", forName: "job")Penggunaan baru: Analytics.setUserProperty("mechanic", forName: "job") | |
Class | |
FIRAnalytics | Analytics |
Konstanta | |
FIRAnalyticsEventAddPaymentInfo | AnalyticsEventAddPaymentInfo |
FIRAnalyticsEventAddToCart | AnalyticsEventAddToCart |
FIRAnalyticsEventAddToWishlist | AnalyticsEventAddToWishlist |
FIRAnalyticsEventAppOpen | AnalyticsEventAppOpen |
FIRAnalyticsEventBeginCheckout | AnalyticsEventBeginCheckout |
FIRAnalyticsEventCampaignDetails | AnalyticsEventCampaignDetails |
FIRAnalyticsEventCheckoutProgress | AnalyticsEventCheckoutProgress |
FIRAnalyticsEventEarnVirtualCurrency | AnalyticsEventEarnVirtualCurrency |
FIRAnalyticsEventEcommercePurchase | AnalyticsEventEcommercePurchase |
FIRAnalyticsEventGenerateLead | AnalyticsEventGenerateLead |
FIRAnalyticsEventJoinGroup | AnalyticsEventJoinGroup |
FIRAnalyticsEventLevelUp | AnalyticsEventLevelUp |
FIRAnalyticsEventLogin | AnalyticsEventLogin |
FIRAnalyticsEventPostScore | AnalyticsEventPostScore |
FIRAnalyticsEventPresentOffer | AnalyticsEventPresentOffer |
FIRAnalyticsEventPurchaseRefund | AnalyticsEventPurchaseRefund |
FIRAnalyticsEventRemoveFromCart | AnalyticsEventRemoveFromCart |
FIRAnalyticsEventSearch | AnalyticsEventSearch |
FIRAnalyticsEventSelectContent | AnalyticsEventSelectContent |
FIRAnalyticsEventSetCheckoutOption | AnalyticsEventSetCheckoutOption |
FIRAnalyticsEventShare | AnalyticsEventShare |
FIRAnalyticsEventSignUp | AnalyticsEventSignUp |
FIRAnalyticsEventSpendVirtualCurrency | AnalyticsEventSpendVirtualCurrency |
FIRAnalyticsEventTutorialBegin | AnalyticsEventTutorialBegin |
FIRAnalyticsEventTutorialComplete | AnalyticsEventTutorialComplete |
FIRAnalyticsEventUnlockAchievement | AnalyticsEventUnlockAchievement |
FIRAnalyticsEventViewItem | AnalyticsEventViewItem |
FIRAnalyticsEventViewItemList | AnalyticsEventViewItemList |
FIRAnalyticsEventViewSearchResults | AnalyticsEventViewSearchResults |
FIRAnalyticsParameterAchievementID | AnalyticsParameterAchievementID |
FIRAnalyticsParameterAdNetworkClickID | AnalyticsParameterAdNetworkClickID |
FIRAnalyticsParameterAffiliation | AnalyticsParameterAffiliation |
FIRAnalyticsParameterCampaign | AnalyticsParameterCampaign |
FIRAnalyticsParameterCharacter | AnalyticsParameterCharacter |
FIRAnalyticsParameterCheckoutStep | AnalyticsParameterCheckoutStep |
FIRAnalyticsParameterCheckoutOption | AnalyticsParameterCheckoutOption |
FIRAnalyticsParameterContent | AnalyticsParameterContent |
FIRAnalyticsParameterContentType | AnalyticsParameterContentType |
FIRAnalyticsParameterCoupon | AnalyticsParameterCoupon |
FIRAnalyticsParameterCreativeName | AnalyticsParameterCreativeName |
FIRAnalyticsParameterCreativeSlot | AnalyticsParameterCreativeSlot |
FIRAnalyticsParameterCurrency | AnalyticsParameterCurrency |
FIRAnalyticsParameterDestination | AnalyticsParameterDestination |
FIRAnalyticsParameterEndDate | AnalyticsParameterEndDate |
FIRAnalyticsParameterFlightNumber | AnalyticsParameterFlightNumber |
FIRAnalyticsParameterGroupID | AnalyticsParameterGroupID |
FIRAnalyticsParameterIndex | AnalyticsParameterIndex |
FIRAnalyticsParameterItemBrand | AnalyticsParameterItemBrand |
FIRAnalyticsParameterItemCategory | AnalyticsParameterItemCategory |
FIRAnalyticsParameterItemID | AnalyticsParameterItemID |
FIRAnalyticsParameterItemLocationID | AnalyticsParameterItemLocationID |
FIRAnalyticsParameterItemName | AnalyticsParameterItemName |
FIRAnalyticsParameterItemList | AnalyticsParameterItemList |
FIRAnalyticsParameterItemVariant | AnalyticsParameterItemVariant |
FIRAnalyticsParameterLevel | AnalyticsParameterLevel |
FIRAnalyticsParameterLocation | AnalyticsParameterLocation |
FIRAnalyticsParameterMedium | AnalyticsParameterMedium |
FIRAnalyticsParameterNumberOfNights | AnalyticsParameterNumberOfNights |
FIRAnalyticsParameterNumberOfPassengers | AnalyticsParameterNumberOfPassengers |
FIRAnalyticsParameterNumberOfRooms | AnalyticsParameterNumberOfRooms |
FIRAnalyticsParameterOrigin | AnalyticsParameterOrigin |
FIRAnalyticsParameterPrice | AnalyticsParameterPrice |
FIRAnalyticsParameterQuantity | AnalyticsParameterQuantity |
FIRAnalyticsParameterScore | AnalyticsParameterScore |
FIRAnalyticsParameterSearchTerm | AnalyticsParameterSearchTerm |
FIRAnalyticsParameterShipping | AnalyticsParameterShipping |
FIRAnalyticsParameterSignUpMethod | AnalyticsParameterSignUpMethod |
FIRAnalyticsParameterSource | AnalyticsParameterSource |
FIRAnalyticsParameterStartDate | AnalyticsParameterStartDate |
FIRAnalyticsParameterTax | AnalyticsParameterTax |
FIRAnalyticsParameterTerm | AnalyticsParameterTerm |
FIRAnalyticsParameterTransactionID | AnalyticsParameterTransactionID |
FIRAnalyticsParameterTravelClass | AnalyticsParameterTravelClass |
FIRAnalyticsParameterValue | AnalyticsParameterValue |
FIRAnalyticsParameterVirtualCurrencyName | AnalyticsParameterVirtualCurrencyName |
FIRAnalyticsUserPropertySignUpMethod | AnalyticsUserPropertySignUpMethod |
Auth
Sebelumnya | Baru |
---|---|
Functions | |
FIRAuth.h | |
init?(app:) | auth(app:) |
Penggunaan sebelumnya:
let auth = FIRAuth(app: myApp)Penggunaan baru: let auth = Auth.auth(app: myApp) | |
FIRUser.h | |
updateEmail(_:completion:) | updateEmail(to:completion:) |
Penggunaan sebelumnya:
user.updateEmail("firebase_rox42@gmail.com") { error in // Check for error }Penggunaan baru: user.updateEmail(to: "firebase_rox42@gmail.com") { error in // Check for error } | |
updatePassword(_:completion:) |
updatePassword(to:completion:) |
Penggunaan sebelumnya:
user.updatePassword("hunter2") { error in // Check for error }Penggunaan baru: user.updatePassword(to: "hunter2") { error in // Check for error } | |
profileChangeRequest() |
createProfileChangeRequest() |
Penggunaan sebelumnya:
let request = user.profileChangeRequest()Penggunaan baru: let request = user.createProfileChangeRequest() | |
getTokenWithCompletion(_:) |
getToken(completion:) |
Penggunaan sebelumnya:
user.getTokenWithCompletion() { token, error in // Handle token or error here }Penggunaan baru: user.getToken() { token, error in // Handle token or error here } | |
Class | |
FIRAdditionalUserInfo | AdditionalUserInfo |
FIRActionCodeInfo | ActionCodeInfo |
FIRAuth | Auth |
FIRAuthCredential | AuthCredential |
FIRAuthDataResult | AuthDataResult |
FIRAuthErrors | AuthErrors |
FIRSecureTokenService | SecureTokenService |
FIRUser | User |
FIRUserProfileChangeRequest | UserProfileChangeRequest |
FIRUserInfo | UserInfo |
FIREmailAuthProvider | EmailAuthProvider |
FIRFacebookAuthProvider | FacebookAuthProvider |
FIRGitHubAuthProvider | GitHubAuthProvider |
FIRGoogleAuthProvider | GoogleAuthProvider |
FIROAuthProvider | OAuthProvider |
FIRTwitterAuthProvider | TwitterAuthProvider |
Konstanta | |
FIRAuthErrorDomain | AuthErrorDomain |
FIRAuthErrorNameKey | AuthErrorNameKey |
FIREmailAuthProviderID | EmailAuthProviderID |
FIRFacebookAuthProviderID | FacebookAuthProviderID |
FIRGitHubAuthProviderID | GitHubAuthProviderID |
FIRGoogleAuthProviderID | GoogleAuthProviderID |
FIRTwitterAuthProviderID | TwitterAuthProviderID |
FIRAuthStateDidChange | AuthStateDidChange |
Pernyataan Jenis | |
FIRAuthStateDidChangeListenerHandle | AuthStateDidChangeListenerHandle |
FIRAuthStateDidChangeListenerBlock | AuthStateDidChangeListenerBlock |
FIRAuthDataResultCallback | AuthDataResultCallback |
FIRAuthResultCallback | AuthResultCallback |
FIRProviderQueryCallback | ProviderQueryCallback |
FIRSendPasswordResetCallback | SendPasswordResetCallback |
FIRConfirmPasswordResetCallback | ConfirmPasswordResetCallback |
FIRVerifyPasswordResetCodeCallback | VerifyPasswordResetCodeCallback |
FIRApplyActionCodeCallback | ApplyActionCodeCallback |
FIRVerificationResultCallback | VerificationResultCallback |
Enum | |
FIRActionDataKey | ActionDataKey |
FIRActionCodeOperation | ActionCodeOperation |
FIRAuthErrorCode | AuthErrorCode |
Inti
Sebelumnya | Baru |
---|---|
Functions | |
FIRAnalyticsConfiguration.sharedInstance() | AnalyticsConfiguration.shared() |
FIRApp.configure(withName:options:) |
FirebaseApp.configure(name:options:) |
Penggunaan sebelumnya:
FIRApp.configure(withName: "myCustomApp", options: customOptions)Penggunaan baru: FirebaseApp.configure(name: "myCustomApp", options: customOptions) | |
FIRApp.defaultApp() |
FirebaseApp.app() |
FIRApp.init?(named:) |
FirebaseApp.app(name:) |
Penggunaan sebelumnya:
let app = FIRApp(named: "myCustomApp")Penggunaan baru: let app = FirebaseApp.app(name: "myCustomApp") | |
FIRApp.allApps() |
FirebaseApp.allApps |
Penggunaan sebelumnya:
for app in FIRApp.allApps() { print("App name: \(app.name)") }Penggunaan baru: for app in FirebaseApp.allApps { print("App name: \(app.name)") } | |
FIRConfiguration.sharedInstance() | FirebaseConfiguration.shared() |
FIROptions.default() | FirebaseOptions.defaultOptions() |
Properti | |
FIROptions | |
GCMSenderID | gcmSenderID |
Class | |
FIRAnalyticsConfiguration | AnalyticsConfiguration |
FIRApp | FirebaseApp |
FIRConfiguration | FirebaseConfiguration |
FIROptions | FirebaseOptions |
Pernyataan Jenis | |
FIRAppVoidBoolCallback | FirebaseAppVoidBoolCallback |
Enum | |
FIRLoggerLevel | FirebaseLoggerLevel |
Error
Sebelumnya | Baru |
---|---|
Functions | |
FIRCrashMessage(_:) |
FirebaseCrashMessage(_:) |
Database
Sebelumnya | Baru |
---|---|
Properti | |
FIRDatabase.h | |
persistenceEnabled | isPersistenceEnabled |
Class | |
FIRDataSnapshot | DataSnapshot |
FIRDatabase | Database |
FIRDatabaseQuery | DatabaseQuery |
FIRDatabaseReference | DatabaseReference |
FIRMutableData | MutableData |
FIRServerValue | ServerValue |
FIRTransactionResult | TransactionResult |
Pernyataan Jenis | |
FIRDatabaseHandle | DatabaseHandle |
Enum | |
FIRDataEventType | DataEventType |
Dynamic Links
Sebelumnya | Baru |
---|---|
Functions | |
// FIRDynamicLinks.h | |
dynamicLink(fromUniversalLinkURL:) | dynamicLink(fromUniversalLink:) |
Class | |
FIRDynamicLink | DynamicLink |
FIRDLRetrievalDelegate | DLRetrievalDelegate |
FIRDynamicLinks | DynamicLinks |
FIRDynamicLinkGoogleAnalyticsParameters | DynamicLinkGoogleAnalyticsParameters |
FIRDynamicLinkIOSParameters | DynamicLinkIOSParameters |
FIRDynamicLinkItunesConnectAnalyticsParameters | DynamicLinkItunesConnectAnalyticsParameters |
FIRDynamicLinkAndroidParameters | DynamicLinkAndroidParameters |
FIRDynamicLinkSocialMetaTagParameters | DynamicLinkSocialMetaTagParameters |
FIRDynamicLinkNavigationInfoParameters | DynamicLinkNavigationInfoParameters |
FIRDynamicLinkComponentsOptions | DynamicLinkComponentsOptions |
FIRDynamicLinkComponents | DynamicLinkComponents |
Pernyataan Jenis | |
FIRDynamicLinkResolverHandler | DynamicLinkResolverHandler |
FIRDynamicLinkUniversalLinkHandler | DynamicLinkUniversalLinkHandler |
FIRDynamicLinkShortenerCompletion | DynamicLinkShortenerCompletion |
Enum | |
FIRDynamicLinkMatchConfidence | DynamicLinkMatchConfidence |
FIRDLRequiredMatchConfidence | DLRequiredMatchConfidence |
FIRDLRetrieveResult | DLRetrieveResult |
FIRShortDynamicLinkPathLength | ShortDynamicLinkPathLength |
ID instance
Sebelumnya | Baru |
---|---|
Functions | |
FIRInstanceID.h | |
getWithHandler() |
getIDWithHandler() |
Penggunaan sebelumnya:
FIRInstanceID.instanceID().get { identity, error in // Check identity and error }Penggunaan baru: instanceID.instanceID().getID { identity, error in // Check identity and error } | |
deleteWithHandler() |
deleteIDWithHandler() |
Penggunaan sebelumnya:
FIRInstanceID.instanceID().delete { error in // Check error }Penggunaan baru: instanceID.instanceID().deleteID { error in // Check error } | |
Class | |
FIRInstanceID | InstanceID |
Konstanta | |
FIRInstanceIDScopeFirebaseMessaging | InstanceIDScopeFirebaseMessaging |
FIRInstanceIDTokenRefresh | InstanceIDTokenRefresh |
Pernyataan Jenis | |
FIRInstanceIDTokenHandler | InstanceIDTokenHandler |
FIRInstanceIDDeleteTokenHandler | InstanceIDDeleteTokenHandler |
FIRInstanceIDHandler | InstanceIDHandler |
FIRInstanceIDDeleteHandler | InstanceIDDeleteHandler |
Enum | |
FIRInstanceIDError | InstanceIDError |
FIRInstanceIDAPNSTokenType | InstanceIDAPNSTokenType |
Undangan
Sebelumnya | Baru |
---|---|
Class | |
FIRInvites | Invites |
FIRInvitesTargetApplication | InvitesTargetApplication |
FIRReceivedInvite | ReceivedInvite |
Konstanta | |
FIRInvitesErrorDomain | InvitesErrorDomain |
Enum | |
FIRInvitesErrorCode | InvitesErrorCode |
FIRReceivedInviteMatchType | ReceivedInviteMatchType |
Protokol | |
FIRInviteBuilder | InviteBuilder |
FIRInviteDelegate | InviteDelegate |
Messaging
Sebelumnya | Baru |
---|---|
Functions | |
FIRMessaging | |
connect(completion:) | connect(handler:) |
Class | |
FIRMessagingMessageInfo | MessagingMessageInfo |
FIRMessagingRemoteMessage | MessagingRemoteMessage |
FIRMessaging | Messaging |
Konstanta | |
FIRMessagingSendSuccess | MessagingSendSuccess |
FIRMessagingSendError | MessagingSendError |
FIRMessagingMessagesDeleted | MessagingMessagesDeleted |
FIRMessagingConnectionStateChanged | MessagingConnectionStateChanged |
FIRMessagingRegistrationTokenRefreshed | MessagingRegistrationTokenRefreshed |
Pernyataan Jenis | |
FIRMessagingFCMTokenFetchCompletion | MessagingFCMTokenFetchCompletion |
FIRMessagingDeleteFCMTokenCompletion | MessagingDeleteFCMTokenCompletion |
Enum | |
FIRMessagingError | MessagingError |
FIRMessagingMessageStatus | MessagingMessageStatus |
FIRMessagingAPNSTokenType | MessagingAPNSTokenType |
Protokol | |
FIRMessagingDelegate | MessagingDelegate |
Remote Config
Sebelumnya | Baru |
---|---|
Functions | |
FIRRemoteConfig | |
setDefaultsFromPlistFileName(_:) | setDefaults(fromPlist:) |
setDefaultsFromPlistFileName(_:namespace) | setDefaults(fromPlist:namespace) |
Class | |
FIRRemoteConfigValue | RemoteConfigValue |
FIRRemoteConfigSettings | RemoteConfigSettings |
FIRRemoteConfig | RemoteConfig |
Konstanta | |
FIRNamespaceGoogleMobilePlatform | NamespaceGoogleMobilePlatform |
FIRRemoteConfigThrottledEndTimeInSecondsKey | RemoteConfigThrottledEndTimeInSecondsKey |
FIRRemoteConfigErrorDomain | RemoteConfigErrorDomain |
Pernyataan Jenis | |
FIRRemoteConfigFetchCompletion | RemoteConfigFetchCompletion |
Enum | |
FIRRemoteConfigFetchStatus | RemoteConfigFetchStatus |
FIRRemoteConfigError | RemoteConfigError |
FIRRemoteConfigSource | RemoteConfigSource |
Penyimpanan
Sebelumnya | Baru |
---|---|
Functions | |
FIRStorageReference | |
put(_:) | putData(_:) |
put(_:metadata:) | putData(_:metadata:) |
put(_:metadata:completion:) | putData(_:metadata:completion:) |
putFile(_:) | putFile(from:) |
putFile(_:metadata:) | putFile(from:metadata:) |
putFile(_:metadata:completion:) | putFile(from:metadata:completion:) |
data(withMaxSize:completion:) | getData(maxSize:completion:) |
metadata(completion:) | getMetadata(completion:) |
update(_:completion:) | updateMetadata(_:completion:) |
Class | |
FIRStorage | Storage |
FIRStorageDownloadTask | StorageDownloadTask |
FIRStorageMetadata | StorageMetadata |
FIRStorageObservableTask | StorageObservableTask |
FIRStorageReference | StorageReference |
FIRStorageTask | StorageTask |
FIRStorageTaskSnapshot | StorageTaskSnapshot |
FIRStorageUploadTask | StorageUploadTask |
Konstanta | |
FIRStorageErrorDomain | StorageErrorDomain |
Enum | |
FIRStorageTaskStatus | StorageTaskStatus |
FIRStorageErrorCode | StorageErrorCode |
Protokol | |
FIRStorageTaskManagement | StorageTaskManagement |
Pernyataan Jenis | |
FIRStorageHandle | StorageHandle |
FIRStorageVoidDataError | StorageVoidDataError |
FIRStorageVoidError | StorageVoidError |
FIRStorageVoidMetadata | StorageVoidMetadata |
FIRStorageVoidMetadataError | StorageVoidMetadataError |
FIRStorageVoidSnapshot | StorageVoidSnapshot |
FIRStorageVoidURLError | StorageVoidURLError |