Notification permission never “granted” on iOS standalone app

I’ve researched and tried a few things now, but I just can not access the expo token because the permission was allegedly not set. Everything I’ve found so far helped me a lot, but in the end it was not the answer.

I have to say that I’m an absolute Apple noob. I know myself with Linux systems, but from Apple devices I have little clue.

I’m writing an app that should notify users when mails are received or there are changes at the database level. The user should not be able to send any notifications, but only receive them. Everything worked immediately on Android, but as always it makes an Apple harder than it has to.

Requirements specification:

I have based my source code on the example of Expo. The builds are automatically generated at the end by Expo.

I had tried it manually some time ago, but with that i had my difficulty with all the certificates and keys from Apple. It always came to errors with the certificates which is why I had let it at some point. I would post the error here later, when I will try again soon. Currently I’m still waiting for the exam by Apple is finished.

If I test the app over Expo before I compile it, reading the expo token works fine. But once the build is done, I can not read a token through both TestFlight and the app itself. The status is still “undetermined”.

So I researched and noticed that I am missing certificates. Now I have the Apple ID, the iOS Distribution Certificate, the Apple Push Services Certificate and the Expo Push Notifications Key. Also a provisioning profile for what ever I need it. And despite the fact that I click on “Allow” after installation, the status is returned “undetermined”. The settings of the iPhone are also set so that notifications are allowed.

Then I tried the command “expo build: ios --clear-push-cert”. Same result. I have updated Node, NPM, Yarn and the expo-cli. Everything else I found was not very helpful for my case. Does anyone have an idea where my mistake is?

export const _getNotificationPermissions = () => (
    new Promise(async (resolve, reject) => {
            const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS)
            let finalStatus = existingStatus

            if (existingStatus !== 'granted') {

                const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS)
                finalStatus = status
            }

            if ('granted' === finalStatus) {

                if ('android' === Platform.OS) {
                    Expo.Notifications.createChannelAndroidAsync('test-members', {
                        name: 'Mail Service',
                        sound: true,
                    })
                }

                const token = await Notifications.getExpoPushTokenAsync()
                token.then(resolve(token))
                    .catch(() => reject('Notifications allowed but there occurs an error at receiving the expo Token.'))
            } else {
                reject('Notifications not allowed. Status: ' + finalStatus)
            }
        }))

EDIT: Meanwhile I found out that I had misunderstood something with the APNs and Push Notification Key and need only one of them. But that would only mean that I’m back at the beginning. Because I had only the key and not the certificate.

If I want to compile the app manually, Expo always has a problem finding a project for the Apple ID. So I’m stuck.

I have now switched to the SDK version 33, but that does not seem to be the right solution. Because in the Troubleshooting iOS I had read the following:
“Note: Push Notifications are currently unavailable with ad hoc clients until we complete our work to add an extra authentication layer to the Expo Push Notification service.”
Ad hoc is automatically selected when Expo compiles the app. Especially since I would not know what else you can take and how to integrate it properly.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.