0
votes

I am wondering if anyone has managed to specify the Firebase user UID that is typically auto generated for you when you create an account. The reason I want to do this is that in my app, we are dealing with doctors and patients. A doctor can create a patient an account, which they can 'claim' to turn them into a standard firebase user, or they can leave it as unclaimed. Either way, this patient account can be shared to other doctors so that doctors can read consult notes etc.

A doctor has to be an auth'd firebase user, and as such has a firebase generated UID as their key in a users node. Patients that have not claimed their accounts live in an unclaimedUsers node. The only difference between the users and the unclaimed users is that a patients primarykey will be their email address, while a users primary key will be their firebase UID that is generated when they create their account.

Instead of having them stored via their email addresses in an 'unclaimed users' node, i would like the unclaimed users to be stored using UIDs that I can then tell firebase to use when I create accounts for them and move their user object from the unclaimedUsers to the users node.

This is so that when an account is claimed, there won't need to be any updates throughout the data structure, as before an account is claimed, it can still be shared, and having a mixture of UIDs and email address' isn't clean.

I have looked into both the REST and iOS SDKs for firebase, and there doesn't appear to be a way you can set the UID that the account will be allocated - using both the standard email/password Auth functions, and the social functions. The only method I haven't tried yet is rolling my own custom auth, as I loose many of the benefits of firebase if i were to do this.

The structure I am using is attached - where the top object is named user, this would be a UID so something like DdxfJdkR0JX1fpXcV07eotxn3M33 - where the second object says unclaimed, this would be someones email address.

"user": { "address": "1 infinity loop", "country": "AU", "displayPicture": "https://static.pexels.com/photos/7720/night-animal-dog-pet.jpg", "dob": "13/09/1991", "email": "[email protected]", "firstName": "henry", "lastName": "hardy", "mobileNumber": "0400000000", "postcode": "Z4351", "pushNotifications": true }, "unclaimed": { "address": "1 infinity loop", "country": "AU", "displayPicture": "https://static.pexels.com/photos/7720/night-animal-dog-pet.jpg", "dob": "13/09/1991", "email": "[email protected]", "firstName": "henry", "lastName": "hardy", "mobileNumber": "0400000000", "postcode": "Z4351", "pushNotifications": true }

1

1 Answers

0
votes

try to save Firebase endpoint into your database, and make sure you make some api to changes endpoint if endpoint is retrieved from firebase API. Because endpoint id will expired sometimes

If you want to notice specific user you can query by their email or something to get their endpoint subscription id.