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

[react-native-hms-push] HmsPushInstanceId.getToken error #275

Open
JACA26 opened this issue May 2, 2023 · 2 comments
Open

[react-native-hms-push] HmsPushInstanceId.getToken error #275

JACA26 opened this issue May 2, 2023 · 2 comments

Comments

@JACA26
Copy link

JACA26 commented May 2, 2023

Description
I installed the react-native-hms-push package and configured all ok, run the app on emulator o phisical device all its ok but when i generate the apk for test i have this error when i get the token of device

Screenshots
If applicable, add screenshots to help explain your issue

Error image

The code to obtain the token is this:
`
export async function getTokenFCM() {
// Register the device with FCM
const isHuawei = await validateHuaweiDevice();
let token = '';
if (Platform.OS !== 'ios') {
if (!isHuawei) {
await messaging().registerDeviceForRemoteMessages();
}
}

// Get the token

if (Platform.OS === 'ios') {
token = await messaging().getAPNSToken();
} else {
if (isHuawei) {
token = await HmsPushInstanceId.getToken();
token =
token['result'] && parseInt(token['resultCode']) === 0
? token['result']
: '';
} else {
token = await messaging().getToken();
}
}

console.log('TOKEN OBTAINED', token);

return token;
}
`

Environment

  • Platform: React Native - "react-native": "0.69.4",
  • Kit: Push
  • Kit Version "@hmscore/react-native-hms-push": "^6.7.0-300",
  • OS Version Android 10
  • Node Version v16.17.0 - npm 8.15.0

Other
the validateHuaweiDevice function return a Boolean with the @hmscore/react-native-hms-availability service

@nkostop
Copy link

nkostop commented May 11, 2023

You need to change this line
token = await HmsPushInstanceId.getToken();
With this:
token = await HmsPushInstanceId.getToken('');

Essentially you need an empty string argument for the getToken method.

@MrutyunjayaB
Copy link

In case of iOS, i am getting HmsPushInstanceId as null itself.
How can i fix it

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

3 participants