diff --git a/messaging/integration_test/src/integration_test.cc b/messaging/integration_test/src/integration_test.cc index aedbe2a093..dcd5ec862d 100644 --- a/messaging/integration_test/src/integration_test.cc +++ b/messaging/integration_test/src/integration_test.cc @@ -354,6 +354,8 @@ TEST_F(FirebaseMessagingTest, TestReceiveToken) { EXPECT_TRUE(RequestPermission()); + EXPECT_TRUE(::firebase::messaging::IsTokenRegistrationOnInitEnabled()); + FLAKY_TEST_SECTION_BEGIN(); EXPECT_TRUE(WaitForToken()); diff --git a/messaging/src/android/cpp/messaging.cc b/messaging/src/android/cpp/messaging.cc index ac2018116c..dff7aacea6 100644 --- a/messaging/src/android/cpp/messaging.cc +++ b/messaging/src/android/cpp/messaging.cc @@ -713,21 +713,13 @@ void Terminate() { static void InstallationsGetToken() { FIREBASE_ASSERT_MESSAGE_RETURN_VOID(internal::IsInitialized(), kMessagingNotInitializedError); - JNIEnv* env = g_app->GetJNIEnv(); - - // Intent intent = new Intent(this, RegistrationIntentService.class); - jobject new_intent = env->NewObject( - util::intent::GetClass(), - util::intent::GetMethodId(util::intent::kConstructor), g_app->activity(), - registration_intent_service::GetClass()); + Future result = GetToken(); - // startService(intent); - jobject component_name = env->CallObjectMethod( - g_app->activity(), - util::context::GetMethodId(util::context::kStartService), new_intent); - assert(env->ExceptionCheck() == false); - env->DeleteLocalRef(component_name); - env->DeleteLocalRef(new_intent); + result.OnCompletion( + [](const Future& result, void* voidptr) { + NotifyListenerOnTokenReceived(result.result()->c_str()); + }, + nullptr); } static void SubscriptionUpdateComplete(JNIEnv* env, jobject result, diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 4ed5bae95e..67e11fc3e9 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -567,10 +567,16 @@ code. ## Release Notes +### Future Release +- Changes + - Messaging (Android): Fixes an issue to receive token when + initialize the app. + ([#667](https://github.com/firebase/firebase-cpp-sdk/pull/667)). + ### 8.5.0 - Changes - General: Updating Android and iOS dependencies to the latest. - - General: Fix the generating of proguard file + - General: Fixes an issue with generating Proguard files. ([#664](https://github.com/firebase/firebase-cpp-sdk/pull/664)). ### 8.4.0