Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): get instanceId #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 6.1.3
version: 6.1.4
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: titanium-firebase-core
Expand Down
21 changes: 21 additions & 0 deletions android/src/firebase/core/TitaniumFirebaseCoreModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
*/
package firebase.core;

import androidx.annotation.NonNull;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.installations.FirebaseInstallations;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
Expand Down Expand Up @@ -38,6 +44,21 @@ public TitaniumFirebaseCoreModule()

// Public APIs

@Kroll.method
public void getInstanceId() {
FirebaseInstallations.getInstance().getId()
.addOnCompleteListener(task -> {
KrollDict kd = new KrollDict();
if (task.isSuccessful()) {
kd.put("value", task.getResult());
kd.put("status", "success");
} else {
kd.put("value", 0);
kd.put("status", "error");
}
fireEvent("instanceId", kd);
});
}
@Kroll.method
public boolean configure(@Kroll.argument(optional = true) KrollDict param)
{
Expand Down