Skip to content

Change the way to achieve token while init the app #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions messaging/integration_test/src/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ TEST_F(FirebaseMessagingTest, TestReceiveToken) {

EXPECT_TRUE(RequestPermission());

EXPECT_TRUE(::firebase::messaging::IsTokenRegistrationOnInitEnabled());

FLAKY_TEST_SECTION_BEGIN();

EXPECT_TRUE(WaitForToken());
Expand Down
20 changes: 6 additions & 14 deletions messaging/src/android/cpp/messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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<std::string>& result, void* voidptr) {
NotifyListenerOnTokenReceived(result.result()->c_str());
},
nullptr);
}

static void SubscriptionUpdateComplete(JNIEnv* env, jobject result,
Expand Down
8 changes: 7 additions & 1 deletion release_build_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,16 @@ code.

## Release Notes

### Future Release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to the actual version number of the upcoming release at the next opportunity, per http://go/firebase-cpp-release.

- Changes
- Messaging (Android): Fixes an issue to receive token when
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed instad of Fixes

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
Expand Down