Unable t0 create a token using Notifications.getExponentPushTokenAsync()

#1

Hi,
I am trying out push notifications on my iphone (6s)
My code gets stuck at Notifications.getExponentPushTokenAsync
The status shows as granted but the rest of the code doesnot execute.
I do not see any errors either.

I am not sure how to resolve this issue.

Code Snippet:

export default async () => {
  let previousToken = await AsyncStorage.getItem('pushtoken');
  console.log(previousToken);
  if (previousToken) {
    return;
  } else {
    let { status } = await Permissions.askAsync(Permissions.REMOTE_NOTIFICATIONS);
    console.log("status", status);
 
    if (status !== 'granted') {
      return;
    }
 
    let token = await Notifications.getExponentPushTokenAsync().catch((error) => console.log(error));
    console.log("token", token)
    await axios.post(PUSH_ENDPOINT, { token: { token } });
    AsyncStorage.setItem('pushtoken', token);
    console.log(AsyncStorage.getItem('pushtoken'));
  }
};
#2

Hi, what does Permissions.getAsync() return? This code will try to ask for permissions every time even if the user has already denied permissions.