Please provide the following:
- SDK Version: 40.0.0
- Platforms(Android/iOS/web/all): Android
I’m working on an expo app and I’ve added expo push notifications and that’s working for iOS but not on android. The problem is caused by getExpoPushTokenAsync() because it doesn’t resolve.
I’m working with Expo version 40.0.0 and using the following code to get the notification token:
export async function registerForPushNotificationsAsync(t) {
if (Constants.isDevice) {
const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
let finalStatus = existingStatus;
if (existingStatus !== 'granted') {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
if (finalStatus !== 'granted') {
alert(t('no_access_push_notifications'));
return;
}
const token = await Notifications.getExpoPushTokenAsync();
return token;
// this.setState({ expoPushToken: token });
} else {
console.log("No physical device");
}
if (Platform.OS === 'android') {
Notifications.setNotificationChannelAsync('default', {
name: 'default',
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: '#FF231F7C',
});
}
};
I’ve created a new project in Firebase according to the Expo docs for Android and copied the google-services.json to the root of my app and linked it in my app.json
{
"project_info": {
"project_number": "xxxxxxxxx",
"project_id": "xxxxxxxxx",
"storage_bucket": "xxxxxxxxx"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "xxxxxxxxx",
"android_client_info": {
"package_name": "xxxxxxxxx"
}
},
"oauth_client": [
{
"client_id": "xxxxxxxxx",
"client_type": 3
}
],
"api_key": [
{
"current_key": "xxxxxxxxx"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "xxxxxxxxx",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
My app.json contains the following code:
"android": {
"package": "xxxxx",
"versionCode": 4050,
"googleServicesFile": "./google-services.json",
"config": {
"googleSignIn": {
"apiKey": "xxxxx"
}
},
"useNextNotificationsApi": true
},
Any thoughts on this?