"Couldn't get GCM token..." on self-built app

Hello everyone!

I’ve faced a problem with notifications on self-prepared APK build (by turtle-cli). I send a request for new expo token, but I always get in response the same message: Couldn't get GCM token for device; I’ve also checked the same code but using expo build:android instead of turtle, and it works. Is there any problem with expo’s notifications on turtle-built applications or maybe I should do some extra steps before build?

This is what I have in my project (SDK 33):

  1. app.json:
...
   "android": {
     "package": "com.robertd.expopush",
     "googleServicesFile": "./google-services.json"
   }

google-services.json

...
  "client": [
    {
      "client_info": {
        "android_client_info": {
          ...
          "package_name": "com.robertd.expopush"
        }
      },
...

in App.js:

const expoToken = await Notifications.getExpoPushTokenAsync()

Which causes problem and returns: Couldn't get GCM token...

Thanks in advance for answers and tips :).

Hi! Have you already followed these instructions for FCM? (including uploading server key w/ expo push:android:upload --api-key <your-token-here>) Make sure you’re logged into the same expo account when you do this

Odd that this only happens in turtle-built apps…what version of turtle are you using, and what version of expo-cli?

Hi, thanks for your answer!

I added API key by expo push and I was logged in, but, when I build my APK, I use turtle build:android without credentials (I pass --public-url instead of them); Should I be logged in to expo before I run turtle build? :thinking:

$ turtle --version
0.9.1
$ expo --version
2.21.2 

UPDATED:

I’ve just tried to run turtle build:android with credentials (params username and password`) and being logged in to expo. Unfortunately, I still have the same error :confused:


UPDATED:

Tested on higher versions of turtle/expo, the same result:

$ turtle --version
0.11.1
$ expo --version
3.0.9

One more thought. Do I need a created project on my account? I have no projects there so far because I published/built everything on my servers. Maybe this is the case? :thinking:

From the Turtle docs:

In order to build your standalone Expo app, you first need to have successfully published your project.

Hm, what does it mean exactly published your project? I published my assets on my personal hosting and I defined it in --public-url, is it not sufficient?

Problem is solved. For everyone who is interested in the solution:

Make sure you have proper id in exported assets (especially: android-index.json). I don’t know why I had @anonymous/project-name there. Finally, after several tries, logins and logouts, I exported assets with id field: @_robertd/project-name and it solved my problem with FCM. I don’t know the reason why previous export had an anonymous id, but it was a problem.

@charliecruzan thanks for your help and patience! :slight_smile:

Using the opportunity: Thanks ExpoTeam, you do a great job!

2 Likes

Happy you got it working! And thanks for sharing the fix :smile:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.