Please provide the following:
- SDK Version: 37
- Platforms(Android/iOS/web/all): Standalone Android app (managed)
Hello everyone,
Got a strange one for ya. On initial load of my application, the user is presented with a push notification permission view, and if they click accept, this function is triggered
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') {
return Alert.alert(
'Notifications are Disabled',
"Would you like to be navigated to your phone's settings to update this permission?",
[
// Stop here if the user did not grant permissions
{
text: 'No Thanks',
onPress: () => navigation.navigate(RouteNames.HomeScreen),
style: 'cancel',
},
// Navigation user to app's settings screen to set permissions there
{
text: 'OK',
onPress: () => {
Linking.openSettings()
navigation.navigate(RouteNames.HomeScreen)
},
},
],
{ cancelable: false }
)
}
// Get the token that identifies this device
const PushToken = await Notifications.getExpoPushTokenAsync()
const UserEmail = await AsyncStorage.getItem('email')
if (Platform.OS === 'android') {
Notifications.createChannelAndroidAsync('default', {
name: 'default',
sound: true,
priority: 'max',
vibrate: [0, 250, 250, 250],
})
}
// POST the token to your backend server from where you can retrieve it to send push notifications.
return registerPushToken({
UserEmail,
PushToken,
}).then(() => navigation.navigate(RouteNames.HomeScreen))
}
If everything goes accordingly, the user will be pushed to the home screen and, if they accept, the BE will receive the expo token that is generated. This works flawlessly in iOS, both standalone and locally (expo server spun up and using a real iOS device over network) and for android locally.
The issue is for standalone android users. Nothing happens if the user clicks the “OK” button. They are just stuck there. I really can’t log anything out to figure out where, in the function, it’s hung up on since it’s a standalone app on an android device. The BE also does not receive the expo token so it appears that its hung up on the askAsync/getAsync. Any help here??
- if it helps, this app was not setup with firebase correctly, so I know it will not be receive notifications, but it should still be able to get/ask for notifications permissions and get an expo token without a firebase set up, right??