Greetings, All.
I have a build with expo sdk 31.
this is my code for doing the permissions for push notifications
async function registerForPushNotificationsAsync() {
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;
}
let token = await Notifications.getExpoPushTokenAsync();
}
in the apple id of the app on the apple developer website, I have permissions enabled under the app id configuration under “capabilities” and two certificates (development and production)
when I console.log on the simulator, or use alert on the device, the status always returns as ‘undetermined’
same behaviour on the simulator and on the device (app in apple store)
no dialog is even opened to request permission from the user to grant push notification permissions.
thanks !
when I run the snack on my device, it shows
Origin:
Data:
push to send notification
expo asked for permissions to send notification, which I allowed.
pushing the ‘push to send notification’ did not do anything.
the error that I am experiencing happens when I run from expo start on an iphone simulator and when I run the app from the Apple store on an iPad.
thanks for your help !
Yeah, it’ll output the Expo push token in the console, and you’ll need to use that in the code to send notifications to your device. I suggest looking through the Push Notifications docs
OK, thanks very much. I do have your code running on my device. I downloaded the snack and after an npm install, was able to run it on the cli. Thanks very much for this. I was able to add your code to the App.js of my project, and when I ran it on the device, it seemed to work, however, after I published it, when i ran it on the same device (not Expo, but the app I had built for iOS) i got the error ‘Failed to get push token for push notification!’
what might be different here? or should I build:ios and publish a newer version?