test on real device still got no push notification permission on iphone

my home page

import React from 'react';
import {
	View,

} from 'react-native';

import { Permissions, Notifications } from 'expo'
import i18n from 'i18n-js';

async function registerForPushNotificationsAsync() {
	// console.log('mama')
	const { status: existingStatus } = await Permissions.getAsync(
		Permissions.NOTIFICATIONS
		);
	let finalStatus = existingStatus;


	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 token that uniquely identifies this device
  let token = await Notifications.getExpoPushTokenAsync();
  console.log('push', token)
}


export default class HomeScreen extends React.Component {
	state = {}
	
	async componentDidMount(){
		console.log('aa')
		registerForPushNotificationsAsync()
		let token = await Notifications.getExpoPushTokenAsync();
		console.log(token)
		
	}
	render() {
		return (
			<View></View>
		);
	}
}

error

Question.

What does it mean by testing on real device? I yarn start on the terminal, the use the iphone to scan the bar code. Then I run the app on iphone. Does this mean I’m testing on real device?

On the iphone, I did see asking for permission to use notification, I pressed ok.

Problem: I can’t access push token, as you can see, the error in the photo I attached. What am I missing?

just found out I need to login expo in the terminal.

open terminal and run

expo login

1 Like

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