Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DeviceInfo.getUniqueID is not a function

The react-native project I'm working on already use react-native-device-info. When I tried to add Android-${DeviceInfo.getUniqueID()} to a header in a request, I get this error:

  { TypeError: DeviceInfo.getUniqueID is not a function
        at makeRequest (~/code/rn/src/services/api-client.js:46:39)

How can that be? I import it like this on the top of the files it is used in.

import * as DeviceInfo from 'react-native-device-info';

If I change the import statement to import DeviceInfo from 'react-native-device-info';, then I get this error:

TypeError: _reactNativeDeviceInfo2.default.getUniqueID is not a function

export function makeRequest(endpoint, method, token, csrfToken = null, body = null) {
    const config = {
        method,
        credentials: 'same-origin',
        headers: {
            Applikasjon: 'KONSERNAPP',
            Accept: 'application/json',
            'X-App-Version': `Android-${DeviceInfo.getUniqueID()}`,
            'Content-Type': 'application/json',
            token,
        },
        timeout: 120000,
    };
like image 523
martins Avatar asked Oct 19 '17 13:10

martins


2 Answers

since react-native-device-info is upgraded to 4.x.x its method typo is bit changed, it is now accepting DeviceInfo.getUniqueId() instead of DeviceInfo.getUniqueID()

like image 145
Soban Arshad Avatar answered Nov 11 '22 04:11

Soban Arshad


This solved it for me DeviceInfo.getUniqueId() instead of DeviceInfo.getUniqueID(). Lolz. It's a typo in the documentation

like image 43
Guillermo Blanco Avatar answered Nov 11 '22 03:11

Guillermo Blanco