in FriendlyPix/AppDelegate.swift [205:238]
func signed(in user: User) {
blockedRef = database.reference(withPath: "blocked/\(user.uid)")
blockingRef = database.reference(withPath: "blocking/\(user.uid)")
observeBlocks()
let imageUrl = user.isAnonymous ? "" : user.providerData[0].photoURL?.absoluteString
// If the main profile Pic is an expiring facebook profile pic URL we'll update it automatically to use the permanent graph API URL.
// if let url = imageUrl, url.contains("lookaside.facebook.com") || url.contains("fbcdn.net") {
// let facebookUID = user.providerData.first { (userinfo) -> Bool in
// return userinfo.providerID == "facebook.com"
// }?.providerID
// if let facebook = facebookUID {
// imageUrl = "https://graph.facebook.com/\(facebook)/picture?type=large"
// }
// }
let displayName = user.isAnonymous ? "Anonymous" : user.providerData[0].displayName ?? ""
var values: [String: Any] = ["profile_picture": imageUrl ?? "",
"full_name": displayName]
if !user.isAnonymous, let name = user.providerData[0].displayName, !name.isEmpty {
values["_search_index"] = ["full_name": name.lowercased(),
"reversed_full_name": name.components(separatedBy: " ")
.reversed().joined(separator: "")]
}
if notificationGranted {
values["notificationEnabled"] = true
notificationGranted = false
}
database.reference(withPath: "people/\(user.uid)")
.updateChildValues(values)
}