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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No GetDeviceId getter #12

Open
ak1987 opened this issue Jun 13, 2021 · 0 comments
Open

No GetDeviceId getter #12

ak1987 opened this issue Jun 13, 2021 · 0 comments

Comments

@ak1987
Copy link

ak1987 commented Jun 13, 2021

I didn't found appDeviceId getter method.
I've never worked with Java language, so don't blame code quality.
My workaround was:

private void handleGetDeviceId(MethodCall call, Result result) {
        try {
            System.out.println("Getting DeviceID");
            final String[] deviceId = new String[1];
            AppMetricaDeviceIDListener listener = new AppMetricaDeviceIDListener() {
                @Override
                public void onLoaded(@Nullable String s) {
                    deviceId[0] = s;
                    System.out.println("s loaded: " + s);
                    System.out.println("deviceId[0] set: " + deviceId[0]);
                }

                @Override
                public void onError(@NonNull AppMetricaDeviceIDListener.Reason reason) {
                    System.out.println("DeviceID loading error");
                }
            };
            YandexMetrica.requestAppMetricaDeviceID(listener);
            TimeUnit.SECONDS.sleep(1);
            System.out.println("deviceId[0] loaded: " + deviceId[0]);
            result.success(deviceId[0]);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage(), e);
            result.error("Error getting Device ID", e.getMessage(), null);
        }
    }

It worked. Please fell free to take it as a starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant