Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android can't extend Firebase Messaging Service

Tags:

I am trying to implement Firebase Cloud Messaging in my application, I had implemented all settings to use this service, but when I try to extend FirebaseMessagingService in my class it gives me error and it can't find it at all, I can't even import com.google.firebase.messaging.FirebaseMessagingService as shown in the picture:

enter image description here

I had added all the code required: I added this to app gradle

compile 'com.google.firebase:firebase-core:9.4.0'  apply plugin: 'com.google.gms.google-services' 

and this to the module gradle:

classpath 'com.google.gms:google-services:3.0.0' 

this is the manifest code:

<application     android:allowBackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:supportsRtl="true"     android:theme="@style/AppTheme">     <activity android:name=".MainActivity">         <intent-filter>             <action android:name="android.intent.action.MAIN" />              <category android:name="android.intent.category.LAUNCHER" />         </intent-filter>     </activity>     <service         android:name=".MyFirebaseMessagingService">         <intent-filter>             <action android:name="com.google.firebase.MESSAGING_EVENT"/>         </intent-filter>     </service>     <service         android:name=".MyFirebaseInstanceIDService">         <intent-filter>             <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>         </intent-filter>     </service> </application> 

and I added the google json file to the app. So if anybody can help me please

like image 703
Saleh Refaai Avatar asked Sep 06 '16 16:09

Saleh Refaai


People also ask

Is there a limit on Firebase messaging?

Maximum message rate to a single device For Android, you can send up to 240 messages/minute and 5,000 messages/hour to a single device.

How do I send FCM messages to multiple devices at the same time on Android?

Register your app with FirebaseGo to the Firebase console. In the center of the project overview page, click the Android icon (plat_android) or Add app to launch the setup workflow. Enter your app's package name in the Android package name field. What's a package name, and where do you find it?

Do FCM tokens expire?

It doesn't expire though. It renews itself if one of the following happens. According to https://firebase.google.com/docs/cloud-messaging/android/client: -The app deletes Instance ID.


1 Answers

If you want to use messaging, you have to add the messaging module. Right now you only added the core module.

So go ahead and include

compile 'com.google.firebase:firebase-messaging:9.4.0' 

All the available modules can be found at the bottom of https://firebase.google.com/docs/android/setup

like image 90
ElDuderino Avatar answered Oct 20 '22 05:10

ElDuderino