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

Invalid TS return type for getDeviceId() #121

Open
bertrand-caron opened this issue May 4, 2022 · 3 comments
Open

Invalid TS return type for getDeviceId() #121

bertrand-caron opened this issue May 4, 2022 · 3 comments

Comments

@bertrand-caron
Copy link

bertrand-caron commented May 4, 2022

Hi,

While browsing the docs, I encounter the following sentence:

You can retrieve the Device ID that Amplitude uses with Amplitude.getInstance().getDeviceId(). This method can return null if a Device ID has not been generated yet.

However, the types list it as returning a string:

getDeviceId(instanceName: string): Promise<string>;

Shouldn't this be changed to getDeviceId(instanceName: string): Promise<string | null>;?

@yuhao900914
Copy link
Contributor

Hi @bertrand-caron , thanks for your feedback.
Yes, deviceId is possible to be null if it's not initialized yet on the native side. It should be changed like what you mentioned.

@jeff-polls
Copy link

@yuhao900914 this issue is causing crashes in my app. What is the recommended method if we need to get the Device ID once it is initialized? Currently we are doing await init() then await getDeviceId() but on first launch we're getting null

@bertrand-caron
Copy link
Author

@jeff-polls @yuhao900914 I also experiences issues with getDeviceId() returning null; would love to add that to the roadmap if possible?

@justin-fiedler justin-fiedler linked a pull request Jun 10, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants