Android Firebase Push Notification not received

Mobile Technologies Mobile Computing 2 years ago

1 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ I followed the tutorial from this link http://blog.nkdroidsolutions.com/android-push-notification-example-using-firebase/ but I am not not receiving any notification on my device. I checked and tried these links too, but could not find a solution android - Firebase Notification Push Notification not working Push Notification not Received in android In my firebase console, the notification sent is 0. Here is my androidManifest File The gradle file is as follows apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.0" defaultConfig { applicationId "com.example.ather.healthapp" minSdkVersion 15 targetSdkVersion 24 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile project(path: ':volley') repositories { mavenCentral() } // this line must be included to integrate with Firebase compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.jakewharton:butterknife:8.1.0' compile 'com.google.android.gms:play-services-auth:9.6.1' compile 'com.google.android.gms:play-services:9.6.1' compile 'com.android.support:support-v4:24.2.1' compile 'com.sothree.slidinguppanel:library:3.0.0' compile 'com.android.support:design:24.2.1' compile 'com.google.firebase:firebase-core:9.6.1' compile 'com.google.firebase:firebase-messaging:9.6.1' } apply plugin: 'com.google.gms.google-services' Firebase Messaging Service file package FirebaseConnection; import android.util.Log; import com.google.firebase.messaging.RemoteMessage; public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService { private static final String TAG = "FCM Service"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { Log.d(TAG, "From: " + remoteMessage.getFrom()); // Check if message contains a data payload. if (remoteMessage.getData().size() > 0) { Log.d(TAG, "Message data payload: " + remoteMessage.getData()); } // Check if message contains a notification payload. if (remoteMessage.getNotification() != null) { Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); } } } And the Firebase ID Service package FirebaseConnection; import android.util.Log; import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.iid.FirebaseInstanceIdService; public class FirebaseIDService extends FirebaseInstanceIdService { private static final String TAG = "FirebaseIDService"; @Override public void onTokenRefresh() { // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.d(TAG, "Refreshed token: " + refreshedToken); // TODO: Implement this method to send any registration to your app's servers. sendRegistrationToServer(refreshedToken); } /** * Persist token to third-party servers. * * Modify this method to associate the user's FCM InstanceID token with any server-side account * maintained by your application. * * @param token The new token. */ private void sendRegistrationToServer(String token) { // Add custom implementation, as needed. } } Any help would be appreciated. Regards

Posted on 30 Aug 2022, this text provides information on Mobile Computing related to Mobile Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago
_x000D_ The problem is the name of your class! Manifest: MyFirebaseMessagingService Service class: FirebaseMessagingService the name of the two must be the same

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Mobile Technologies Links

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community