Hey @adamjnav
Thanks for the reply.That’s exactly what I thought so.But I get:
Couldn’t get GCM token for device
When I just use expo client app itself.let me put my code so you can take a look this is my package.json:
{
“main”: “node_modules/expo/AppEntry.js”,
“scripts”: {
“start”: “expo start”,
“android”: “expo start --android”,
“ios”: “expo start --ios”,
“web”: “expo start --web”,
“eject”: “expo eject”
},
“dependencies”: {
“@expo/vector-icons”: “^10.0.6”,
“expo”: “^35.0.0”,
“expo-constants”: “~7.0.0”,
“expo-font”: “~7.0.0”,
“expo-linear-gradient”: “~7.0.0”,
“expo-permissions”: “~7.0.0”,
“lodash”: “latest”,
“react”: “16.8.3”,
“react-dom”: “16.8.3”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz”,
“react-native-animatable”: “^1.3.3”,
“react-native-animated-flatlist”: “0.0.3”,
“react-native-gesture-handler”: “~1.3.0”,
“react-native-paper”: “^3.1.1”,
“react-native-reanimated”: “~1.2.0”,
“react-native-screens”: “~1.0.0-alpha.23”,
“react-navigation”: “^4.0.10”,
“react-navigation-drawer”: “^2.3.3”,
“react-navigation-fluid-transitions”: “^0.3.2”,
“react-navigation-header-buttons”: “^3.0.3”,
“react-navigation-material-bottom-tabs”: “^2.1.5”,
“react-navigation-stack”: “^1.10.3”,
“react-navigation-tabs”: “^2.5.6”,
“react-redux”: “^7.1.1”,
“redux”: “^4.0.4”,
“redux-thunk”: “^2.3.0”
},
“devDependencies”: {
“babel-preset-expo”: “^7.1.0”
},
“private”: true
}
And here’s my code:
const registerForPushNotifications = async () =>{
//Get the current users id So you can post the token to the user in your database
const currentUser = JSON.parse(await AsyncStorage.getItem(‘auth’)).userId;
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
let finalStatus = existingStatus;
// only ask if permissions have not already been determined, because
// iOS won’t necessarily prompt the user a second time.
if (existingStatus !== ‘granted’) {
// Android remote notification permissions are granted during the app
// install, so this will only ask on iOS
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
console.log(existingStatus);
}
// Stop here if the user did not grant permissions
if (finalStatus !== 'granted' && Constants.isDevice) {
return;
}
// Get the token that uniquely identifies this device
try{
let token = await Notifications.getExpoPushTokenAsync();
// POST the token to your backend server from where you can retrieve it to send push notifications.
var updates = {};
console.log(token);
}
catch(error){
console.log(error)
}
};
And also I need to mention I’m using a real android devices running android 7.0
So could you please tell me why I get this error?
Couldn’t get GCM token for device