Cannot resolve method "GetApplicationContext()" in FirebaseInstanceIDService class

Viewed 328

I'm trying to run an android application but due to errors cannot build the gradle. Found the code from Internet and trying to run it, Can't figure it out what's wrong.

Intent registrationComplete = new Intent(Config.REGISTRATION_COMPLETE);
    registrationComplete.putExtra("token", refreshedToken);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

private void sendRegistrationToServer(final String token) {
    // sending gcm token to server
    Log.e(TAG, "sendRegistrationToServer: " + token);
}

private void storeRegIdInPref(String token) {
    SharedPreferences pref = getApplicationContext().getSharedPreferences(Config.SHARED_PREF, 0);
    SharedPreferences.Editor editor = pref.edit();
    editor.putString("regId", token);
    editor.commit();
}

These 2 errors are shown while I run on emulator:

incompatible types: MyFirebaseInstanceIDService cannot be converted to Context, cannot find symbol method getApplicationContext().

0 Answers
Related