Socials: ▻Instagram: ▻Twitter: ▻Facebook: Hi, Im starting with new serie, I want to show you …

Nguồn:https://u-os.org/

Author

48 Comments

  1. Actual versions today:
    implementation 'com.squareup.retrofit2:retrofit:2.7.1'

    implementation 'com.squareup.retrofit2:converter-gson:2.7.1'

    implementation 'com.google.firebase:firebase-messaging:20.1.0'

    4:40: instead of – FirebaseInstanceIdService;
    use – FirebaseMessagingService;

  2. Chong you yuan Reply

    Thanks for your tutorial! You have done a great work!

  3. Calisto Chipfumbu Reply

    @19:54, if I may please know where you are getting the (userid), I cant seem to see that in the series.

  4. Gajanan Korde Reply

    when i click on received notification, it won't take me take me to the MessageActivity, my app is getting crashed at that time
    it shows below runtime exception

    E/AndroidRuntime: FATAL EXCEPTION: main

    Process: com.gajanan.example.chatappusingfirebase, PID: 26804

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gajanan.example.chatappusingfirebase/com.gajanan.example.chatappusingfirebase.MessageActivity}: java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)

    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)

    at android.app.ActivityThread.access$800(ActivityThread.java:141)

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)

    at android.os.Handler.dispatchMessage(Handler.java:102)

    at android.os.Looper.loop(Looper.java:136)

    at android.app.ActivityThread.main(ActivityThread.java:5052)

    at java.lang.reflect.Method.invokeNative(Native Method)

    at java.lang.reflect.Method.invoke(Method.java:515)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)

    at dalvik.system.NativeStart.main(Native Method)

    Caused by: java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()

    at com.google.firebase.database.DatabaseReference.child(com.google.firebase:firebase-database@@16.0.4:101)

    at com.gajanan.example.chatappusingfirebase.MessageActivity.onCreate(MessageActivity.java:131)

    at android.app.Activity.performCreate(Activity.java:5242)

    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)

    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249) 

    at android.app.ActivityThread.access$800(ActivityThread.java:141) 

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212) 

    at android.os.Handler.dispatchMessage(Handler.java:102) 

    at android.os.Looper.loop(Looper.java:136) 

    at android.app.ActivityThread.main(ActivityThread.java:5052) 

    at java.lang.reflect.Method.invokeNative(Native Method) 

    at java.lang.reflect.Method.invoke(Method.java:515) 

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796) 

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612) 

    at dalvik.system.NativeStart.main(Native Method)

  5. itaye elenzweig Reply

    Loved your videos so far. really helpful.
    But why are you using a class that is already deprecated?
    Now they've deleted it completely and I don't know how to continue or with what to replace it.

  6. vishal mishra Reply

    no explanation atleast explain the steps while coding.

  7. vishal mishra Reply

    why we cannot only use firebase cloud messaging .what is the need to use retrofit plz explain

  8. ahmed elabbasy Reply

    how i can send notifiction form user to all user
    i have button take a pic on my app
    and i need when user taked a pic this pic send to all user app in notifiction

  9. Gaurav kumar Reply

    sir, i have an error in extend class FirebaseInstanceIdServices

  10. Techi lovers Reply

    hello sir, i need your help. i am not getting message notification, I am receiving token at server end in firebase, cloud notification are workig fine . but message notification not working, please help me on that? Thank you in advance sir!!!

  11. Ibn dzair ابن الجزائر Reply

    when i clicked on the notification l app crashe why!!

  12. PETER UKEME Reply

    Kod dev pls add chatrooms in this app. Pls

    The app has the following features:

    Sending a message to all users joining to the room.Notifies when each user joins or leaves.Notifies when an user start typing a message. And text colour

  13. Rizki nanda mustaqim Reply

    why the notifications just work on API 23 ??? on other API version not working, please help me

  14. Singye pelthy Reply

    i cannot import firebaseInstanceIdServices….so how can i do that?

  15. Musharraf Faheem Reply

    My System.UI is crashing when recieving notification??? Any idea how to make it correct

  16. Gerzha Project Reply

    i got error pls help

    com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to type com.example.myapp.Notifications.Token

    the problem is on "Token token = ds.getValue(Token.class);
    "
    please somebody help

    private void sendNotification(final String hisUid, final String nama, final String message) {

    DatabaseReference allTokens = FirebaseDatabase.getInstance().getReference("Tokens");

    Query query = allTokens.orderByKey().equalTo(hisUid);

    query.addValueEventListener(new ValueEventListener() {

    @Override

    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

    for (DataSnapshot ds: dataSnapshot.getChildren()){

    Token token = ds.getValue(Token.class);

    Data data = new Data(myUid, nama+":"+message, "New Message", hisUid, R.drawable.profile);

    Sender sender = new Sender(data, token.getToken());

    apiService.sendNotification(sender)

    .enqueue(new Callback<Response>() {

    @Override

    public void onResponse(Call<Response> call, retrofit2.Response<Response> response) {

    Toast.makeText(ChatActivity.this, ""+response.message(), Toast.LENGTH_SHORT).show();

    }

    @Override

    public void onFailure(Call<Response> call, Throwable t) {

    }

    });

    }

    }

    @Override

    public void onCancelled(@NonNull DatabaseError databaseError) {

    }

    });

    }

    My token.java

    public class Token {

    public String token;

    public Token(String token) {

    this.token = token;

    }

    public Token() {

    }

    public String getToken() {

    return token;

    }

    public void setToken(String token) {

    this.token = token;

    }

    }

  17. Hermes Obiang Reply

    FirebaseId Service not available plus i cannot import it. I cannot extend FirebaseId Service
    How to solve error at 04:40 : FirebaseId Service

    MyFirebaseIdService extends FirebaseInstanceIdService [error line]

    error decription: Can't resolve Symbol 'FirebaseInstanceIdService '

  18. Asad Chattha Reply

    How to solve error at 04:40 : FirebaseId Service
    MyFirebaseIdService extends FirebaseInstanceIdService [error line]
    error decription: Can't resolve Symbol 'FirebaseInstanceIdService '

  19. Why i cannot import com.google.firebase.iid.FirebaseInstanceIdService;?

  20. Sikandar Niaz Reply

    FirebaseInstanceIdService is not available what should i do?

  21. Imdadul Haque Reply

    Notification not showing when app killed in customized ROM mobiles like oppo, vivo, xyomi etc. How to solve this?

  22. How can i get the source code ? I am not getting any notification even after trying hundred times.

  23. deep menpara Reply

    didn't get the chatted user list in chat fragment from user side

  24. Kanishk Vijaywargiya Reply

    Keep ur work consistent like this only, my friend ur doing great job…..Niceee

  25. error on 9:30 ! its required '=' expected

    "Content-Type:application/json"

    ,"Authorization = serverkey"

    what is the error please tell me

  26. _muhseen _ Reply

    when I send a message, my app always cras at

    Token token = snapshot.getValue(Token.class);

  27. Septian Triiawan Parapak Reply

    08:30 If you wondering why ur notification not show.. You need to replace key with ur own server key from Firebase project.

  28. Wanderlust 555 Reply

    Hi, will appreciate if anyone who encountered the same error can help (sented is null for some reason): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at (FirebaseMessaging.java:37)

  29. Himanshu Malik Reply

    clicking on notification crashes the app, because userid is null which is passed from UserAdapter, and if we click the notification it directly open the MessageActivity without getting intent from UserAdapter.

    *UserAdapter
    in onBindViewHolder()

    Intent openMessage=new Intent(mContext, MessageActivity.class);

    openMessage.putExtra("userId",user.getId());

    mContext.startActivity(openMessage);

  30. souha kerkeni Reply

    help me java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference

    at com.example.ecoleprimairee.Notifications.MyFirebaseMessaging.onMessageReceived(MyFirebaseMessaging.java:24)

    if(firebaseUser!=null && sented.equals ( firebaseUser.getUid () )){

    sendNotification ( remoteMessage );

    }

  31. Cupuw Gaming Reply

    Is something wrong with this? Why?
    (Caused by: java.lang.IllegalArgumentException: Illegal URL: htpps://fcm.googleapis.com/)

  32. Antonius Putra Reply

    Can't convert object of type java.lang.String to type com.example.asus.program.notification.Token
    why?

  33. Rachid Insa Reply

    For those having problem receiving notifications, try this : in the MyFirebaseMessaging class override onNewToken and copy the function updateToken from the MyFirebaseIdService to the MyFirebaseMessaging class then you can delete the MyFirebaseIDService, so you should have something like this in MyFirebaseMessaging class:
    @Override
    public void onNewToken(String s) {
    super.onNewToken(s);
    String refreshToken = FirebaseInstanceId.getInstance().getInstanceId().getResult().getToken();
    if (refreshToken != null){
    updateToken(refreshToken);
    }
    }

    private void updateToken(String refreshToken) {
    if (FirebaseAuth.getInstance().getCurrentUser() != null){
    FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();

    DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Tokens");
    Token token = new Token(refreshToken);
    reference.child(firebaseUser.getUid()).setValue(token);
    }
    }

Write A Comment