last day (16 days later) » 
16:00 - 19:0019:00 - 22:00

4:39 PM
1
A: Create products Google play and in-app billing

Peter HaddadRegarding firebase you have to do this: First Firebase is a nosql database so it uses JSON to add values to the database. Also Firebase is a service that has realtime database,storage,cloud functions,authentication.So its your best option. Now Regarding the way to store, you can do this: In re...

 
tell me what else you need @Skizo-ozᴉʞS
 
Thanks for your answer @Peter Haddad, but let me see... what's push_id_here? This is what I have to send from the APP? How do I create the db itself, and what about the products on Google Play? And if I need authenticate user, how do I authenticate from my app? Other guys said that buying an item it's like loggin, because it stores the email, right?
 
@Skizo-ozᴉʞS check edit please, the above JSON is the db in firebase its not like sql , its nosql, authentication is a service provided by firebase, so it will authenticate your users, about authenticate firebase.google.com/docs/auth
 
but what's that name push_id_here?
 
@Skizo-ozᴉʞS oh nothing its random id, generated by firebase we cant know its name.. but we can retrieve it from the database doing this String key=ref.getKey(); check image in answer
@Skizo-ozᴉʞS here in the image(from google) chatchat-15e82 is a root node, then channels is like Users node and its child of root node the push ids are below, these random ids are like primary key to identify the name:values inside of it
 
4:39 PM
But I mean I do not know how many users I'll have, I have to send it from my app, right?
 
yes the push id is made through this code push(), its just to seperate records like primary key, so yes from the code, everytime a user is created a push id is done for him also @Skizo-ozᴉʞS
 
But I have to create the db? first?
And this name and email, from where I get? Do I have to implement the Authentication aswell?
 
You create the db from your code and email and password are the text in the edit text.. Then you authenticate them
 
I do not need to sign in with Gmail?
 
Noo it depends what sign in method you choose when authenticing, there is email and password/google sign in / phone number/github
 
4:39 PM
Hello Peter
I have those 3 implements on my code
implementation 'com.google.firebase:firebase-core:11.6.0'
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-database:11.6.0'
 
okay
 
that's okay by the moment?
 
do like I told you, go to tools>firebase>firebase database
 
So I do not have to create a Login/register page?
 
they will add all the implementation for you
yes ofcourse you do, those implementation are for the build.gradle on android
did you register your app in console.firebase.com?
 
4:42 PM
where I put this?
tools>firebase>firebase database
where I can find this?
 
in android studio
u have it opened?
 
there is Tools in the top menu
click on that
 
Connect to Firebase?
 
then click on firebase
yes!
then connect to the database and authentication
 
4:44 PM
ok hold on!
I created a project with different email
and crashed
 
create with the same email
ur personal email..
Tools>firebae>Authentication>email and password authentication
click on email and password authentication and connect to firebase then click add firebase authentication to your app
did you finish it?
 
I need to delete
my project on Firebase
because I used another account
 
you can create another project, and alright
 
but I have to put the same package name right?
 
package name of your project yes
you should be in the console now and your project in android studio should be connected to firebase
 
4:58 PM
ok
now is connected
 
under Develop
now in the console there is on the left tab authentication
 
Do you have Teamviewer?
 
no sorry
 
yes correct
 
5:00 PM
now?
 
your connected now and those implementation they added them automatically in the build.gradle
depends what you want to do..
create a sign up page I guess
but first go to the firebase console, on the left tab and click on authenticate
 
Yes
So I create an Activity and I follow those steps?
 
yes
create normally like your creating any other app
the difference is that you have to add authentication
first go to firebase console and click on authenticate and enable a method did you do that?
 
what did you enable?
 
5:06 PM
Google
 
after the above create an activity with xml normally
 
You did it before?
 
I mean the Auth with Firebase?
 
doing it now
senior project lol
yes
 
5:07 PM
ok
perfect
 
but I did email and password
not gmail
 
So you have experience with it
I can do both, right?
 
yes im sure you can do both
 
perfect!
 
but why make it complicated.. just choose one and dont complicate yourself :p
 
5:08 PM
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "createUserWithEmail:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "createUserWithEmail:failure", task.getException());
This is like if you do email and password?
 
yupp
 
but... I'd like to login with Google
I have to follow this?
 
yes its different than email and password
but the two compiles in the link you should have them in your build.gradle
only need the google sign in method
 
on build.gradle where?
 
out of curiousty is this your first app on android?
those compile 'com.google.firebase:firebase-auth:11.6.0' are in your build.gradle no need to add them
they got added when you connected to firebase automatically
 
5:12 PM
yes this
No, it is not lol
but using Firebase yes
 
alright
look at this code , you and svi.data
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

final String dates=date.getText().toString().trim();
final String number=phone.getText().toString().trim();
final String name=inputname.getText().toString().trim();
final String email = inputEmail.getText().toString().trim();
final String password = inputPassword.getText().toString().trim();
final String confirmpass=confpass.getText().toString().trim();

if (TextUtils.isEmpty(email)) {
Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show();
this is in my app sign up using email and password though, but you get the idea how it should be done
also im storing in the database after sign up in the above
inside this public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
 
But Peter
What does it mean
You must pass your server's client ID to the requestIdToken method. To find the OAuth 2.0 client ID:
Open the Credentials page in the API Console.
The Web application type client ID is your backend server's OAuth 2.0 client ID.
 
thats in google sign
in* but where are you getting those text
 
Peter, can you download Tv?
would be fast
I think I got it
At least the login
 
I cant because the internet is not good where I am right now
anw thats good that the login is done
the database is pretty much like i told you in the answer
 
5:20 PM
what is updateView() method?
 
did you declare it in your code?
do you mean updateUI()?
I dont think there is updateview()..
 
UI sorry
I'm implementing the signIn Button
I'll let you know when I'm ready....
 
5:36 PM
yes ui , it just updates the layout if authentication was successful , if not then write updateUI(null) so nothing changes in layout
 
but what should be updateUI like an Intent?
@PeterHaddad check this out please, could you tell me if looks good or not...
 
no its not an intent
everything related to google sign in seems to be there, what/ if is it not working?
u also authenticated your user in the code
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { here you are doing google authentication...
I guess debug and try it on your device and see if the user you create will be added in the authentication tab in firebase console
 
wow
It's logged
 
finally great lol
 
now I have to store it to firebase db...
because I do not store it
 
5:45 PM
yes I know
 
from now I have login with gmail
 
go to firebase console
click on database tab on the left
and click get started
u should have a root node there, do you have it?
 
okay so lets say you wanna follow the database in my answer
you have a root node in the console
in your code, do this DatabaseReference ref=getInstance().getReference().child("Users");
 
I'd like to create a db like this :
3
A: Create products Google play and in-app billing

Alex MamoThere are good answers here but because you have asked me, i'll try to give you some more details. The best practice for Implementing In-app Billing is the official documentation. Please se below my my answer for some of your questions. As many other users have advised you, so do I, use Firebase...

Looks fine...
 
5:48 PM
okay
then do this DatabaseReference ref=getInstance().getReference().child("Users");
here you create node users
 
but on firebase console?
I have this : myApp:
null
 
yes thats the root node
.child("users") will be its child like in that database...
getInstance().getReference() //here you are getting the instance of your database and the root node
.child("user") will be a child node
 
but I have to press the "+" button
on database?
 
nooo
keep the database as it is
what you write in your code will be added to the database
 
as myApp:null?
ahhh
okok
 
5:54 PM
thats root node
users will be its child node
 
then I have to add DatabaseReference where?
 
if you want in the activity after log in
inside onCreate
 
like splash activity?
 
no normal activity..
 
lol sorry I did not understand you
ok i'll put it after log in
 
5:56 PM
I mean you can save to db after login(another activity) or in the same activity
 
I'll do in the same activity
it's ok?
 
yes should work hopefully
 
ok
when it joins to success login you mean?
 
yes write it inside
if task is sucessful
 
private void handleSignInResult(GoogleSignInResult result){
Log.d(TAG,"handleSignInResult:" + result.isSuccess());
if(result.isSuccess()){
//Signed in
GoogleSignInAccount acct = result.getSignInAccount();
statusTextView.setText("Hello, " + acct.getDisplayName());

}
else{
Log.d(TAG,"Not logged");
}
}
 
5:57 PM
if (task.isSuccessful()) {
 
Under the statusTextView, right?
 
okay try it there
I meant here first: if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
but try it where you said
 
Ya I know... but on tuto I was watching he wasn't using firebase
Should I call this? instead
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success");
 
you mean inside of this if (task.isSuccessful()) { ?
 
6:00 PM
okay try it there
 
I mean what's the difference between this :
 
Im not sure about the other, but I know task.isSuccessful means you are authneticated
thats why I told you try it inside of it
 
perfect
 
okay so write this: DatabaseReference ref=getInstance().getReference().child("users");
then ref.child(user.getUid())
 
cannot find getInstance()
 
6:04 PM
my bad
should be DatabaseReference ref=FirebaseDatabase.getInstance().getReference.child("users");
 
I changed the method
now I'm using the task.suckcessfull
 
use the above
 
looks like it's slower but it's ok
 
what didnt understand?
 
nvm :P
getReference now
is in red
 
6:05 PM
getReference()
 
done
lol
users or Users?
 
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success");
FirebaseUser user = mAuth.getCurrentUser();
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("users");
ref.child(user.getUid());
doesnt matter..
whatever you want thats a node you are creating
 
ok done
 
okay he says this also //user details (name, age, address, email and so on)
 
yes
so, user.getName(),age,address, etc?
 
6:08 PM
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success");
FirebaseUser user = mAuth.getCurrentUser();
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("users");
ref.child(user.getUid());
ref.child("name").setValue(name);
ref.child("age").setValue(age);
ref.child("address").setValue(address);
ref.child("email").setValue(email);
yes the values you should get them from the edittext
 
what editText
I'm implementing Google one remember :P
 
oh right
 
from start I can go with name, email
nothing else
in a future I can edit this?
 
yes write getDisplayName() and getEmail() for those two
but for age, address you probably have to add an edittext and get the value and then set to database
 
Yep
doesn't matter
I'll go with displayName and Email
 
6:12 PM
okay great
btw what products are u selling in this app?
 
are items for the app
Example: I have a dog, and a cat, I can buy a bird, cow, horse, etc
you know?
 
buying pets?
 
not the case
but yes
 
yes I got it
 
I'd like to store
 
6:15 PM
store what?
 
What I have to store is name,img(if it's possible)?
something else?
 
image of user?
 
no, image of pet
 
ohh yes sure u can do that
 
6:16 PM
you have to send it to storage first then get the url in database
 
But I can test that the auth is working?
 
what do you mean?
 
what we have done since now
How do I know it's working?
 
try it on your phone
or emulator
 
I know right, but on console firebase I'll see those?
 
6:18 PM
yes in the database you should see the name and email and user id
and users node
try it on your phone and see
 
perfect!
I see my email and username
 
in database console?
 
great
 
like
-users
-name
-email
 
6:20 PM
yes under user id
there is an id right??
 
ok okay thats great then
 
well I do not see any user Id
 
in console
take a screenshot of your database console
 
Look if I login with other user
it doens't show the 2 users it only shows 1
 
6:23 PM
yes it overrides
did you write this ref.child(user.getUid());??
 
ref.child(user.getUid());
Do I have to set it?
as ref.child("userUid").setValue(user.getUid());?
 
no should be only like this ref.child(user.getUid());
write it like this instead
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("users").child(user.getU‌​id());
the user is this variable FirebaseUser user = mAuth.getCurrentUser();
not another variable...
 
Yes, sure
FirebaseUser user = mAuth.getCurrentUser();
ok
 
okay try it again
 
it's fine now...
 
6:27 PM
2 users appeared?
 
yep
I had to delete
 
yes thats great
 
the userName and email from other, because it created another
 
its fine you delete from database
 
btw, how many users I can store?
 
6:28 PM
what? if there is 2 users then each user should have his own name and email and id
 
Yes, yes it's ok :D
 
not sure as much as u want maybe, but if lots of users then it wont be free anymore
 
Perfect, np
 
btw you can do this DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("users").push() , but this create a random id not userid, ur gonna have to do it for the products I guess
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("products").push() //something like this for the products with push()
 
I have to create another object of DatabaseReference?
 
6:31 PM
for the product node yes
 
on the same page?
Activity, I mean
 
yes
u can do that
U should have a layout idea for the app, but u can create multiple objects for DatabaseReference on the same activity
 
Yes
doesn't appears the products
 
what did you write?
 
DatabaseReference refProds=FirebaseDatabase.getInstance().getReference().child("products").push();
 
6:34 PM
yes wont be appear because you need a value also
 
But I have to create the products
 
like this
DatabaseReference refProds=FirebaseDatabase.getInstance().getReference().child("products").push();
refProds.child("productname").setValue(name);
 
On Google Play console developer?
 
in google play console ur gonna create the products?
 
I guess, yes, no?
I mean, I want to use in-app billing... so I have to buy those products
 
6:37 PM
yes I guess but if you want the products in database you have to add them in the app also so they can be sent to databse
 
Yeah, I know, they should be the same, right?
 
Yes, I checked it
 
they need to be in project also, no other way to sent to database other than this way
u cant send from google play console to firebase database
 
ah ok
 
6:40 PM
yes thats logical
as the link above you have to create a connection between google play console and ur project
 
I have created the product
on Google play console
 
yes u have to establish a connection
Creating a ServiceConnection
 
aham
but from firebase
I have to do something else?
 
basically you have to connect with google console to project, and then the products are synced in the project
then you can store products from project to firebase database
using the stuff I told u above
DatabaseReference refProds=FirebaseDatabase.getInstance().getReference().child("products").push();
refProds.child("productname").setValue(name);
 
Did you did it before? Or you are a senior on Firebase only
 
6:48 PM
nope only know firebase, but by reading the docs thats what I concluded
 
I saw this link
But seems like it's out-dated, and it's not the same...
 
is he speaking english :p
 
Yes
Why?
 
not clear alot
DatabaseReference refProds=FirebaseDatabase.getInstance().getReference().child("products").push();
refProds.child("productname").setValue(name);
refProds.child("price").setValue(price);
cant u add the products in project and sent them to database then take them from project to google play console?
 
not getting u with the last message
 
6:56 PM
I mean add them in project and send them to database
then add them to google play console from project
does that not work?
nevermind wont work
 
16:00 - 19:0019:00 - 22:00

  last day (16 days later) »