how to updata new item in Firebase - ios

I want to add a new item to my list, I use firebase without user(email,password)
I want to add new items like this:
list
vdjs43ndjufd87
"name" : Jak
"university" : Harvard
list
vdjs43ndjufd87
"name" : Jak
"university" : Harvard
"age" : 23
this code is not working for me
let key = ref.child("posts").childByAutoId().key
let post = ["uid": userID,
"author": username,
"title": title,
"body": body]
let childUpdates = ["/posts/\(key)": post,
"/user-posts/\(userID)/\(key)/": post]
ref.updateChildValues(childUpdates)`

Did you check that you were allowed to add items to you database?
By default, the firebase database has a protection that you need to deactivate while you're in development if you didn't implement any connection module for the users of your app yet.
Don't forget to reactivate this protection before submitting your app though!
You can read more about rules here: https://firebase.google.com/docs/database/security/

Related

Test User creation in iTunes connect

When i try to create a test user in my iTunes connect account I am getting an error like "There are one or more validation errors below.". I have filled all fields and there is no errors shown in the fields.
Safari's web inspector is your friend here. Go to Develop->Show Web Inspector, then select the Network tab. Attempt to set up your new sandbox user. You should see a call highlighted in red - this is the HTTP resource that's hit during the attempted account creation. Click on that, and you should see the server response content, which should contain some more helpful details as a JSON payload – something like:
{
"errors" : [ {
"id" : "afafaf-1334-49ae-aaaa-19303ab5b2c8",
"status" : "409",
"code" : "ENTITY_ERROR.ATTRIBUTE.INVALID",
"title" : "The provided entity includes an attribute with an invalid value",
"detail" : "This email address is not available for use as an Apple ID. You may already have an Apple ID associated with this address. Please try again or sign in using your existing Apple ID.",
"source" : {
"pointer" : "/data/attributes/password"
}
} ]
}

Updating stars in Firebase post by transaction

According to the Firebase documentation, it is recommended to duplicate the store data for faster access like so (Firebase example):
let key = ref.child("posts").childByAutoId().key
let post = ["uid": userID,
"author": username,
"title": title,
"body": body]
let childUpdates = ["/posts/\(key)": post,
"/user-posts/\(userID)/\(key)/": post]
ref.updateChildValues(childUpdates)
And, afterwords if you want to add a rating/stars to the post, you should do it with a runTransactionBlock call to a reference:
ref.runTransactionBlock({ (currentData: FIRMutableData) -> FIRTransactionResult in {}
The reference to this last call is the reference to the post you wanna rate
My question is, How are we suppose to update two different references in the same transaction?
Should we make 2 of them? It doesn't seem really safe to me to do it this way
Thank you for your help

Firebase append data to node

How can I append data to a node in Firebase? The value update would just be a string, not a dictionary.
Firebase should be able to increment each items. I thought update would work, but that only updates a dictionary. When I attempt to set the value, it erases everything.
FIRDatabase().reference().database.childRef(refUrl: path).updateChildValues([:])
Example:
node{
1:itemOne
2:itemTwo
3:itemThree
}
From firebase docs
https://firebase.google.com/docs/database/ios/read-and-write
Update specific fields
To simultaneously write to specific children of a node without overwriting other child nodes, use the updateChildValues method.
try something like
let key = ref.child("node").childByAutoId().key
let post = ["uid": userID,
"author": username,
"title": title,
"body": body]
let childUpdates = ["/posts/\(key)": post,
"/user-posts/\(userID)/\(key)/": post]
ref.updateChildValues(childUpdates)

Get event rsvp summary using koala gem in rails

I have been able to retrieve event details using
#graph = Koala::Facebook::API.new(access_token)
#eventSummary = #graph.get_object(eventId)
and getting users list invited using
#eventSummary = #graph.get_connections(eventId, "invited")
I want to get count for all user invited, maybe, Declined and accepted for the event. for which i'm using
#eventSummary = #graph.get_connections(eventId, "invited?summary=1")
which again giving me the list of users only. when used graph.facebook like
https://graph.facebook.com/***eventId***/invited?access_token=*****access_token****&summary=1
i'm getting the count in result.
{
"data": [
{
"name": "xyz",
"rsvp_status": "attending",
"id": "10000000123"
}
],
"paging": {
"next": "https://graph.facebook.com/***eventId***/invited?summary=1&access_token=***accesstoken***&limit=5000&offset=5000&__after_id=100004389574321"
},
"summary": {
"noreply_count": 0,
"maybe_count": 0,
"declined_count": 0,
"attending_count": 1,
"count": 1
}
}
for just solving purpose i'm getting result using fql, as:
#eventSummary = #graph.get_object("fql", :q => "SELECT all_members_count, attending_count, declined_count, not_replied_count, unsure_count FROM event WHERE eid = #{eventId}")
But this is not convenient to use.
Can anyone please help, what am i doing wrong ? To get Event RSVP counts.
I'm using rails v.3.2, for facebook using Koala gem.
Thanks in advance.
I've seen it too, that when you request the event itself, those attendee count fields aren't included. You can use the second parameter to specifically ask for them though:
#eventSummary = #graph.get_object(eventId)
#eventSummary.merge(#graph.get_object(eventId, fields: "attending_count,declined_count,interested_count"))
The first call gets your "standard" event details, something like this:
{"description"=>"Blah blah blah",
"name"=>"My Event Will Rock",
"place"=>{"name"=>"Venue Bar",
"location"=>{"city"=>"Citytown",
"country"=>"United States",
"latitude"=>43.05308,
"longitude"=>-87.89614,
"state"=>"WI",
"street"=>"1216 E Brady St",
"zip"=>"53202"},
"id"=>"260257960731155"},
"start_time"=>"2016-04-22T21:00:00-0500",
"id"=>"1018506428220311"}
The second call gets just those "additional" requested fields:
{"attending_count"=>3,
"declined_count"=>0,
"interested_count"=>12,
"id"=>"1018506428220311"}
You can store them in separate variables, or as I'm suggesting above, use the hash#merge method. (There shouldn't be any problematic overlap between the keys of these two hashes.)
Alternatively, you can get all these details in one request by explicitly requesting everything you want.

how to add open button at the passbook

http://i.stack.imgur.com/K81uU.png
you can see the pic,there is a open button,the pic is passbook pass,i do not find any api or pass attribute to finish it. at the pass.json
"backFields" : [
{
"key" : "extras",
"label" : "Discount",
"value" : "Your friends receive 50% off price"
},
{
"key" : "phone",
"label" : "Phone",
"value" : "800-1234567890"
},
{
"key" : "date",
"label" : "Valid time:",
"dateStyle" : "PKDateStyleMedium",
"timeStyle" : "PKDateStyleNone",
"value" : "2013-01-03T00:00Z"
},
{
"key" : "terms",
"label" : "TERMS AND CONDITIONS",
"value" : "Lessons must be used between 1/1/2013 and 3/1/2013. Appointments for lessons must be made no less than 48 hours in advance. Customer must be able to swim."
}
]
i am not find other key or label to finish it. can you help me
If you want to add link to your application, I believe you should use the associatedStoreIdentifiers top-level key.
Optional. A list of iTunes Store item identifiers (also known as Adam IDs) for the associated apps.
Only one item in the list is used—the first item identifier for an app compatible with the current device. If the app is not installed, the link opens the App Store and shows the app. If the app is already installed, the link launches the app.
http://developer.apple.com/library/ios/#documentation/userexperience/Reference/PassKit_Bundle/Chapters/TopLevel.html

Resources