Migrating¶
From the flat 0.1 modules¶
Every product is now a subpackage:
| Before | Now |
|---|---|
pyios_firebase.firapp.configure() |
pyios_firebase.core.configure() |
pyios_firebase.firfirestore, firfieldvalue, firfilter |
pyios_firebase.firestore |
pyios_firebase.firuser.User |
pyios_firebase.auth.User (also Auth.auth().current_user) |
pyios_firebase.firgoogleauth |
pyios_firebase.auth.google |
pyios_firebase.firappcheck.initialize_debug_appcheck() |
pyios_firebase.app_check.use_debug_provider() (the old name still works) |
Auth changes:
- Sign-in callbacks get
(result, error)like the rest of the library, instead of(data, is_error):resultis anAuthDataResult(result.user.uid), anderroris anAuthError(still withcancelled). User().uid,.emailand.display_namearestrorNone(not Objective-C strings);User().userandUser().authare still the native objects.- Several sign-ins can run at once: each keeps its own callback.
Firestore changes:
- Reads give snapshots:
get_documentgives aDocumentSnapshot, andget_documents/ query listeners give aQuerySnapshot(iterate it like the old list). add_snapshot_listener_for_changesis gone: usesnapshot.document_changes.DocumentReference.set_data(data, callback)is nowset_data(data, merge=False, callback=None). The oldset_data(data, callback)still works.FIRAggregateSourceand the other enums are inpyios_firebase.firestore.- Any exception raised in a transaction function now stops the transaction, and the callback gets the Python value you returned (not an Objective-C object).
- Errors also have a
domainkey. - Booleans are now read as
True/False. Before, they came back as1/0. Nonein data you write is stored asnull. Before, it crashed the app.datetimevalues can be written and used in queries.- Unsupported values raise
TypeErrorin Python instead of failing inside the SDK. snapshot.metadata.is_from_cache,snapshot.metadata.has_pending_writesandquery_snapshot.is_emptywere alwaysTrue(they read Objective-C custom getters without calling them). They now give the real value; code that relied on them, for example to skip pending local writes, behaves differently.
From pyobjus-firebase¶
- Install
pyios-firebaseand follow Setup. - Replace the
pyobjus-firebaseimports in your code with the new ones. - Delete any
.mor.hfiles you added only forpyobjus-firebase. - If something does not work, open an issue in this repository.