Hello, I am testing on an external Iphone since I know push notifs do not work on simulator. My Expo tokens weren’t being sent to my Firebase database so I dug into the code and discovered that my status
variable from async call Permissions.askAsync(Permissions.NOTIFICATIONS)
returns as undetermined
. All the responses I’ve seen on this forum relate to this issue being from a simulator so I’m confused as to why this is happening.
- The first time I opened the app on iphone I allowed push notifications. Just to check here is a screenshot of the notifications panel showing they are on:
Here is the corresponding code I am using essentially straight from docs:
import { Font, AppLoading, Permissions, Notifications } from 'expo';
and the function called on componentDidMount()
registerForPushNotificationsAsync = async (user) => { const { status: existingStatus } = await Permissions.getAsync( Permissions.NOTIFICATIONS ); let finalStatus = existingStatus; // only ask if permissions have not already been determined, because // iOS won't necessarily prompt the user a second time. if (existingStatus !== 'granted') { // Android remote notification permissions are granted during the app // install, so this will only ask on iOS const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS); console.log(status); finalStatus = status; } // Stop here if the user did not grant permissions if (finalStatus !== 'granted') { return; } // Get the token that uniquely identifies this device let token = await Notifications.getExpoPushTokenAsync(); alert(token); var updates = {} updates['/expoToken'] = token; database.ref('users').child(user.uid).update(updates) }
As you can see, I’ve been console logging the status variable and it shows undetermined at that point. How else can I help debug this issue? Thanks!