When Switch to Push Notification Key on iOS, Building Standalone Apps cannot get tokens

when apply push notification key on ios, we can not get token.
We having app inhouse and in process build. we let expo handle anything certs.

Hey @feamobile,

What exactly happens when you call Notifications.getExpoPushTokenAsync? Also, what SDK version are you running for your project?

Cheers,
Adam

initial we using sdk31 and then we upgrade to sdk 33, both all are not working

“Not working” is not very helpful. Explicitly detailing behavior and providing exact errors or warnings allows us to help debug much more effectively.

we are until using expo-client to debug, with expo-client then it working and hadn’t anthing warnings or errors;
but it’s only when build standalone on IOS, I try wapper in try catch, but its’t response

There are my code


import { Permissions, Notifications } from 'expo';
import { Platform } from 'react-native';
import Constants from 'expo-constants';
import notiAPI from './notification';

var promise2 = new Promise(function(resolve, reject) {
  setTimeout(resolve, 5000, 'timeouttoken');
});

export default async function registerForPushNotificationsAsync(usercode, internal) {
  try {
    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;
    }
    console.log('token');
    let token = '';

    token = await Promise.race([Notifications.getExpoPushTokenAsync(), promise2]).then(function(value) {
      return value;
    });
    // alert(token);
    notiAPI.AddToken(
      internal,
      token,
      usercode,
      Constants.deviceName,
      Platform.OS === 'ios' ? 'iOS' : 'Android',
      Constants.manifest.sdkVersion,
      'ITSQCENDLINE'
    );
  } catch (error) {
    console.log(error);
    alert('Cannot get token Pushnotification service!');
  }
}
export async function UnregisterForPushNotificationsAsync() {
  let token = '';
  try {
    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;
    }

    token = await Promise.race([Notifications.getExpoPushTokenAsync(), promise2]).then(function(value) {
      return value;
    });
  } catch (error) {
    alert('Cannot get token Pushnotification service!');
  }
  return token;
}
`

althought I had race Promise but it isn’t return value “timeouttoken”;
I thing this proplem cause in build standlone app on IOS.

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