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

后端 未结 5 1398
有刺的猬
有刺的猬 2020-12-01 13:24

I have a project in eclipse. I need include firebase library. If I was using Android Studio the steps would simply be:

And its all, all library include.

相关标签:
5条回答
  • 2020-12-01 13:57

    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.

    0 讨论(0)
  • 2020-12-01 14:03

    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.

    0 讨论(0)
  • 2020-12-01 14:07

    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.)

    0 讨论(0)
  • 2020-12-01 14:08

    Have a look at the resources below. In short, it's about including the Firebase libraries into your project (see the GitHub project and the two videos at the end) and manually performing the steps that the plugin does for you in Android Studio / Gradle.

    • Firebase libraries for Eclipse
      https://github.com/dandar3/android-google-firebase-README
    • Eclipse: Integrating Firebase Analytics into your Android app
      (same steps apply for other Firebase components, will write a post specifically for Cloud Messaging soon)
      http://dandar3.blogspot.com/2016/11/eclipse-integrate-firebase-analytics.html
    0 讨论(0)
  • 2020-12-01 14:13

    Old code is working no need to change code in firebase only change is in server code you have to use Web API Key from firebase project and Sender ID as per old code style. and you have to replace gcm url in web script - https://fcm.googleapis.com/fcm/send

    No Requirement of firebase library...

    0 讨论(0)
提交回复
热议问题