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

getExpoPushTokenAsync return null in IOS device

$
0
0

I'm working on a push notifications system with Expo. I tried to get token and save it to mobile storage:

/**
   * Demande d'autorisation pour accéder au token du GSM et l'envoyer vers l'api
  */
  registerForPush = async () => {
    if (Constants.isDevice) {
      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') {
        alert('Failed to get push token for push notification!');
        return;
      }
      const gsm = await Notifications.getExpoPushTokenAsync();
      this._storeData('TOKEN_GSM', gsm);
    } else {
      alert('Must use physical device for Push Notifications');
    }
  };

Component Did Mount :

async componentDidMount() {
    console.log("##########  COMPONENT DID MOUNT   ############");
    this.registerForPush();

I got the token in android mobile but in IOS i got null value.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



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