Open JACA26 opened 1 year ago
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.
In case of iOS, i am getting HmsPushInstanceId as null itself. How can i fix it
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
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
Other the validateHuaweiDevice function return a Boolean with the @hmscore/react-native-hms-availability service