Push Notification Not working Couldn't get GCM token for device

First I didn’t setup fcm and thought well expo knows what to do.But it didn’t work and gave me the above message.Then I searched google and found:
https://docs.expo.io/versions/latest/guides/using-fcm/
So I did add it.

Finally, make a new build of your app by running expo build:android .

But the above sentence in the provided link seemed not promising for me.So I tried to ignore it and ran my expo app once more still the same error.As fat as I know the above command will cause it to upload the app to expo servers and generate an apk.So everytime I create a change I must do that?There’s no way getting it work with expo client?So what’s the point?I think it isn’t like that and I’m missing the point.Otherwise how is it even possible to develop an application without building a lot of apks.Or making clones and eject to do the same thing locally.What Am I getting wrong here?Please help me.I’m just testing push notifications with expo and couldn’t get it working yet after 2 hours of trying.

Hey @stevemoretz,

You can test push notifications in the Expo Client without having to do any configuration. Once you are ready to build your standalone Android binary however, you’ll need to do the FCM set up once as the google services file will be baked into your binary so that FCM knows what app to send the push notifications to. From then on, the only time you’ll need to make any changes to FCM-related things is if the key is revoked or you want to swap keys, etc.

Cheers,
Adam

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

Can you run expo push:android:show and see if the expected FCM key is printed out in the console?

Hello @adamjnav here is what I got running that command:

{“status”:“ok”,“fcmApiKey”:" ",“error”:“no database entries found”}

I have also singed in to see if that let’s me if I’m signned in to expo using terminal but no luck

You’ll need to upload the key again via expo push:android:upload and then run the show command to double check that it got properly uploaded.

@adamjnav expo push:android:upload I haven’t used it!You’re saying do it again.So that’s the problem right?I haven’t use that.It gets a fcm key?How do I use this command please?

You can find a step by step guide in the docs you linked to! https://docs.expo.io/versions/latest/guides/using-fcm/#uploading-server-credentials

Oh gosh.The docs misleaded me.
It says:

ExpoKit projects

So I tougth the rest of the page is about that!I’m really sorry.I’ll give that a try thank you so much.

@adamjnav
Hi there.Do I have to be signed in?It still gives me

Couldn’t get GCM token for device

.If I sign in.I get:

This problem if I sign out and then run it’ll go away.In the mean time I followed your guide and get:

{“status”:“ok”,“fcmApiKey”:“AAAAYy1XEW0:APA91bFA5AogJ162ryG1msVF-1JbNb_X9uwUE7OVjOjXY-60OsVjKD1afiWL
tnMF9USdirDAi3Yf1CA0YyRDO0I-oG_9erRQAHDlazwn_5KQN0VDRsaqF2DI1H6UtEr_huZbnaN7P7do”}

When I do

expo push:android:show

So do I have to be signed in?Is that the reason I get

Couldn’t get GCM token for device

Once again I explain.I signed in and checked for expo push:android:show and it gave me that output so I have uploaded the key to expo server I have to sign out and then run the app on my phone Or i’ll get the mentioned problem.And yet I’m getting the first error still I named the topic after.

Couldn’t get GCM token for device

So what shall I do now?