How can I use Firebase cloud message in an eclipse project?

Solution 1:

The new Firebase (9xx) libraries can be found in the Google Repository. You can install this with the Eclipse Android SDK Manager. Open the SDK manager and scroll down until you find Google Repository and install the package.

The package will be installed in /extras/google/m2repository and you will find the Firebase files further down at /com/google/android/firebase.

You can rename the .aar files to .zip and extract the jar file, rename these from classes.jar and copy them to the project libs folder displayed in Eclipse (or copy outside Eclipse and then follow the instructions to import a project into Eclipse.)

Solution 2:

There is a move towards Android Studio with Gradle. The Eclipse solution to Firebase CM is not forthcoming. My feeling is we will all have to move to AS with Gradle soon. There are good books on it and very simple instructions on Google dev sites. We might as well start learning the new IDE and migrate.

Solution 3:

You can add this on your Android Manifest

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
<receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="YOUR PACKAGE NAME" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
            android:exported="false" />

And then you can get the token and try to send Message on.

Dont forget also to build FirebaseApps on your code (in my case on my MainActivity)

FirebaseOptions options = new FirebaseOptions.Builder()
    .setApiKey("YOUR FIREBASE API KEY")
    .setApplicationId("YOUR FIREBASE APP ID")
    .setGcmSenderId("YOUR FIREBASE SENDER ID")
    .build();

FirebaseApp myApp = FirebaseApp.initializeApp(getApplicationContext(), options);
        token = FirebaseInstanceId.getInstance(myApp).getToken();

Hope it will get what you looking for on Eclipse.