Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Notifications.getExpoPushTokenAsync not working on Stand Alone iOS

$
0
0

I'm trying to my expo/react-native project to send push notifications to my server. It works on standalone Android, but not stand alone iPhone.

The standalone iPhone app never sends the token.

Since the app sends nothing without error, I tried removing:

if (finalStatus !== 'granted') { return; }

This didn't work either.

export async function registerForPushNotificationsAsync(token) {  const { status: existingStatus } = await Permissions.getAsync(    Permissions.NOTIFICATIONS  );  let finalStatus = existingStatus;  // Only ask if permissions have not already been determined, for iOS.  if (existingStatus !== 'granted') {    const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);    finalStatus = status;  }  // Stop here if the user did not grant permissions  if (finalStatus !== 'granted') {    return;  }  // Get the push token that uniquely identifies this device  let expoToken = await Notifications.getExpoPushTokenAsync();  // Post new push token to backend for user  return axios({    method: 'POST',    url: `${str.ROOT_URL}/account/push/`,    headers: {      Authorization: `Token ${token}`    },    data: {"token": expoToken,"status": finalStatus    }  });}

I expected the token to get sent to the backend, but nothing is sent on the standalone iOS app.

Please let me know if you know a workaround or had this issue before. Thanks!


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>