Reputation: 1
while doing HmsPushInstanceId.getToken('') to get device token for push notification service, its giving undefined. HmsPushInstanceId itself is showing as null.
Trying to figure out the issue from past 3 days. Can anybody help?
Note: I am using HMS Core for china.
This is how i am trying to retrieve the device token
import {
HmsPushEvent,
HmsPushInstanceId,
HmsPushMessaging,
} from '@hmscore/react-native-hms-push';
import { useEffect } from 'react';
import { isDeviceInChina } from '../../globalization/utils/getCountry';
function useHuwaeiPushService({ setUserAndToken = () => {} }) {
const getHuwaeiPushToken = async () => {
if (!isDeviceInChina()) {
return;
}
HmsPushInstanceId?.getToken('')
.then((result) => {
console.log('getToken::', result);
setUserAndToken((pv) => {
return {
...pv,
messagingToken: result?.result,
};
});
activateHuwaeiPush();
})
.catch((err) => {
console.log(`[getToken] Error/Exception: ${JSON.stringify(err)}`);
});
};
return {
getHuwaeiPushToken,
};
}
export default useHuwaeiPushService;
Upvotes: 0
Views: 99