2

I upgraded my expo push notifications and whenever I run it on Android, I get the below error:

Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager. Please set your Project ID. A valid firebase project ID is required to communicate with Firebase server APIs: It identifies your project with Goolge.

Can anyone tell me where I am supposed to put the project ID? I have it linked up in my project in my config.js file but I feel like it is also supposed to be in my app.json file, just not 100% sure where.

{
  "expo": {
    "name": "Galavant",
    "slug": "Galavant",
    "platforms": ["ios", "android", "web"],
    "version": "2.0.8",
    "orientation": "portrait",
    "icon": "./assets/logo.png",
    "splash": {
      "image": "./assets/logo_original.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "usesAppleSignIn": true,
      "infoPlist": {
        "NSCameraUsageDescription": "So you can add photos to your profile.",
        "NSPhotoLibraryUsageDescription": "So you can add photos to your profile.",
        "NSLocationWhenInUseUsageDescription": "So you can connect with people nearby."
      },
      "supportsTablet": true,
      "bundleIdentifier": "com.test.test",
      "buildNumber": "0.0.1",
      "config": {
        "googleSignIn": {
          "reservedClientId": "com.googleusercontent.apps.12346789"
        }
      }
    },
    "android": {
      "package": "com.test.test",
      "useNextNotificationsApi": true,
      "versionCode": 5,
      "config": {
        "googleMaps": {
          "apiKey": "asdkjfkasjdf9837983rlkajshf"
        },
        "googleSignIn": {
          "apiKey": "asdkjfkasjdf9837983rlkajshf", 
          "certificateHash": "33345w4sdfasdkjfkasjdf9837983srlkajshf"
        }
      },
      "permissions": [
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION",
        "CAMERA",
        "MANAGE_DOCUMENTS",
        "READ_CONTACTS",
        "READ_CALENDAR",
        "WRITE_CALENDAR",
        "READ_EXTERNAL_STORAGE",
        "READ_PHONE_STATE",
        "RECORD_AUDIO",
        "USE_FINGERPRINT",
        "VIBRATE",
        "WAKE_LOCK",
        "WRITE_EXTERNAL_STORAGE",
        "com.anddoes.launcher.permission.UPDATE_COUNT",
        "com.android.launcher.permission.INSTALL_SHORTCUT",
        "com.google.android.c2dm.permission.RECEIVE",
        "com.google.android.gms.permission.ACTIVITY_RECOGNITION",
        "com.google.android.providers.gsf.permission.READ_GSERVICES",
        "com.htc.launcher.permission.READ_SETTINGS",
        "com.htc.launcher.permission.UPDATE_SHORTCUT",
        "com.majeur.launcher.permission.UPDATE_BADGE",
        "com.sec.android.provider.badge.permission.READ",
        "com.sec.android.provider.badge.permission.WRITE",
        "com.sonyericsson.home.permission.BROADCAST_BADGE"
      ]
    },
    "notification": {
      "icon": "./assets/PushNotification.png"
    }
  }
}
Olivia
  • 1,843
  • 3
  • 27
  • 48

3 Answers3

1

I ended up doing a few things. First I created and added in the google-services.json file. I added in the "web" section with the project ID and I finally updated the "android" section with the useNextNotificationsApi

"android": {
  "package": "com.test.test",
  "googleServicesFile": "./google-services.json",
  "useNextNotificationsApi": true,
  "versionCode": 10,
  "config": {
    "googleMaps": {
      "apiKey": "123456789"
    },
    "googleSignIn": {
      "apiKey": "123456789",
      "certificateHash": "123456789asdfasdf"
    }
  },
  "permissions": [
    "ACCESS_COARSE_LOCATION",
    "ACCESS_FINE_LOCATION",
    "CAMERA",
    "USE_FINGERPRINT",
    "VIBRATE"
  ]
},
"web": {
  "config": {
    "firebase": {
      "projectId": "testprojectID",
      "apiKey": "123456789",
      "measurementId": "measurementid123"
    }
  }
},
Olivia
  • 1,843
  • 3
  • 27
  • 48
1

I tried to switch to the Managed Flow in an attempt to work on background notifications (which don't work in Expo Go) and got the exact same error (failed to startup when getting Expo push token while mentioning projectId).

I did end up getting mine working finally. Here's where I stumbled if it helps others...

First, I confirmed that I had these two keys in:

  "googleServicesFile": "./google-services.json",
  "useNextNotificationsApi": true,

Second, I think I didn't run through all of https://docs.expo.dev/push-notifications/using-fcm/ entirely correctly. I had the whole "Client Setup" working but then later forgot to do "Uploading Server Credentials".

Third, and probably the most confusing, I am also new to publishing and updating. I created a debug page on my app that showed the version that it was running from the Play Store (at least I thought it did). But it would only update when I opened after releasing my Play app to Internal Testing and then closed and re-opened it... After learning more about OTA Updates, I realized THAT is actually what was happening and that I wasn't actually getting the latest build with the new android keys set even though my Constants.manifest.android.versionCode's and app versions APPEARED to update (since they somehow got delivered OTA..).

So the final thing that fixed me was to manually uninstall my Internal Testing app via Play and then re-install it from scratch!

Dharman
  • 30,962
  • 25
  • 85
  • 135
Atmas
  • 2,389
  • 5
  • 13
  • Does this work? – MK_Pierce Dec 27 '21 at 16:06
  • It worked for me. But as you can tell by my text there were many issues occurring simultaneously so your results may vary. – Atmas Dec 27 '21 at 23:21
  • `Constants.manifest` turn undefined after to publish an update, you should use `Constants.expoConfig` instead. + you need to reload the app twice to receive the update. – Irfan wani Feb 11 '23 at 06:17
0

what solved my problem was to add in ./android/app/build.grandle in dependencies this

implementation 'com.google.firebase:firebase-iid'

but in my case, I ran into other problems before, for example I forgot to upload the server credentials. The documentation does not make this explicit. On this page the steps are clearer

upload server credentials

you can also check if the path of googleServiceFile is o

Resende
  • 55
  • 6