expo: Expo 35, Push Notifications not working on android "Error: Couldn't get GCM token for device"
🐛 Bug Report
Environment
Expo CLI 3.2.3 environment info: System: OS: macOS 10.14.6 Shell: 5.3 - /bin/zsh Binaries: Node: 12.11.0 - ~/.nvm/versions/node/v12.11.0/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.11.3 - ~/.nvm/versions/node/v12.11.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman IDEs: Android Studio: 3.5 AI-191.8026.42.35.5791312 Xcode: 11.0/11A420a - /usr/bin/xcodebuild npmPackages: expo: ^35.0.0 => 35.0.0 react: 16.8.3 => 16.8.3 react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8 npmGlobalPackages: expo-cli: 3.2.3
Issue is on android, I’ve tested on S7 and One Plus 7 Pro
Steps to Reproduce
Upgrade and old app using push notifications to expo 35. I also tried singling out the problem by creating a new project that only tried getting a token.
Alternatively, you can try the example on the expo page, https://snack.expo.io/@charliecruzan/pushnotifications34?platform=ios which will give the same issue.
Here is the relevant part of my code
async requestNotificationPermissions() {
let { status: latestStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS)
console.log('permission status', latestStatus)
if (latestStatus === 'granted') {
return true
} else {
;({ status: latestStatus } = await Permissions.askAsync(Permissions.NOTIFICATIONS))
if (latestStatus === 'granted') {
return true
}
}
return false
}
async componentDidMount() {
const haveNotificationPermissions = await this.requestNotificationPermissions()
if (!haveNotificationPermissions) {
return
}
try {
const token = await Notifications.getExpoPushTokenAsync()
} catch (e) {
console.log('waaa', e)
}
console.log('ree', token)
}
Expected Behavior
I expected it to correctly get an expo push token
Actual Behavior
I get an error that says
Error: Couldn't get GCM token for device
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 25 (7 by maintainers)
I don’t know if this is relevant or not but i encouter that GCM issue only when I’m not sign in to the expo-cli, after signed in with expo account everything works fine
Please make sure that you are on the latest version of the Expo Client App, that supports the SDK you are running I had the older version of Expo Client (installed in Feb’20) and my react-native project was using SDK 37 released in April. I spent the entire day trying to figure out why the notification service is not working. Then I borrowed my friend’s mobile (also on Android 9) today and it worked. On further digging, saw the expo client release notes published on April 14 about support on SDK 37. Updated my Expo Client Logged in with my Expo account on both CLI and Client Expo Start It Worked!!! Thank God, I found it, was about to switch to FCM. I wonder why I wasn’t prompted by the Expo App to update.
@zifahm & @AakashPat Maybe it was similar for you. SDK 37 released on 31st March and Client was updated on April 14th.
Thank you! I’ve been trying to figure this out literally all day!