Skip to content

Commit 520af2c

Browse files
cynthiajoanCynthia Jiang
and
Cynthia Jiang
authored
Change the way to achieve token while init the app (#667)
* Fix the logic to generate .pro file * update readme file * modify the release notes * Change the way to fetch initial token with the new API * Change the way to fetch initial token with the new API * Add change to release notes Co-authored-by: Cynthia Jiang <[email protected]>
1 parent 521a5b4 commit 520af2c

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

messaging/integration_test/src/integration_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ TEST_F(FirebaseMessagingTest, TestReceiveToken) {
354354

355355
EXPECT_TRUE(RequestPermission());
356356

357+
EXPECT_TRUE(::firebase::messaging::IsTokenRegistrationOnInitEnabled());
358+
357359
FLAKY_TEST_SECTION_BEGIN();
358360

359361
EXPECT_TRUE(WaitForToken());

messaging/src/android/cpp/messaging.cc

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -713,21 +713,13 @@ void Terminate() {
713713
static void InstallationsGetToken() {
714714
FIREBASE_ASSERT_MESSAGE_RETURN_VOID(internal::IsInitialized(),
715715
kMessagingNotInitializedError);
716-
JNIEnv* env = g_app->GetJNIEnv();
717-
718-
// Intent intent = new Intent(this, RegistrationIntentService.class);
719-
jobject new_intent = env->NewObject(
720-
util::intent::GetClass(),
721-
util::intent::GetMethodId(util::intent::kConstructor), g_app->activity(),
722-
registration_intent_service::GetClass());
716+
Future<std::string> result = GetToken();
723717

724-
// startService(intent);
725-
jobject component_name = env->CallObjectMethod(
726-
g_app->activity(),
727-
util::context::GetMethodId(util::context::kStartService), new_intent);
728-
assert(env->ExceptionCheck() == false);
729-
env->DeleteLocalRef(component_name);
730-
env->DeleteLocalRef(new_intent);
718+
result.OnCompletion(
719+
[](const Future<std::string>& result, void* voidptr) {
720+
NotifyListenerOnTokenReceived(result.result()->c_str());
721+
},
722+
nullptr);
731723
}
732724

733725
static void SubscriptionUpdateComplete(JNIEnv* env, jobject result,

release_build_files/readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,16 @@ code.
567567

568568
## Release Notes
569569

570+
### Future Release
571+
- Changes
572+
- Messaging (Android): Fixes an issue to receive token when
573+
initialize the app.
574+
([#667](https://github.com/firebase/firebase-cpp-sdk/pull/667)).
575+
570576
### 8.5.0
571577
- Changes
572578
- General: Updating Android and iOS dependencies to the latest.
573-
- General: Fix the generating of proguard file
579+
- General: Fixes an issue with generating Proguard files.
574580
([#664](https://github.com/firebase/firebase-cpp-sdk/pull/664)).
575581

576582
### 8.4.0

0 commit comments

Comments
 (0)