Here in this van block,
we now know that we do have granted permissions.
That's the only scenario where we will reach
this van block in the end.
And therefore now here,
we want to sign up with Expo's push service,
which under the hood,
will ensure that those official services get used.
And for that, we can again use that notifications package,
which we imported, this one from Expo notifications.
And there we can call get Expo push token async.
This is a method that will talk to Expo's server.
So not to Google's and Apple's server
but to dead server owned and managed by the Expo team,
so to say, and when I say team, by the way,
that's not just two people working on that.
This is a reliable service backed by a big community.
So we'll talk to that server there.
And we'll sign up our app with that Expo server.
And then behind the scenes,
Expo this server ends on
will know how to deliver push notifications
to the different app installations on the different devices.
So we just need to call that and return the result.
Since this will return a promise,
and then in the next van block,
thereafter, we'll get that result.
So here we'll get some data.
And for the moment,
let's simply log that data to see what's inside there.
Now, if we save that, we'll have a problem though,
we can do this, but this won't work on those simulators.
If we try to run this on the Apple device,
on the iOS simulator,
if I run the project again there, we'll see that ultimately,
nothing is being printed here.
The same for Android, if I quit that,
and restarted on Android
we'll not see any output there as well.
So we're not able to test this on simulators.
Instead, we'll need real devices.
And I'll start with a real iPhone.
So I'm going to quit this Expo server
and restarted with my real iPhone connected.
And now I scan the QR code with my iPhone.
Now I did actually run the app there before,
I have to admit,
that's why I'm not getting prompted
for providing permissions here.
I did have to do that before.
So you should be prompted.
And now there, with that connected,
we should be able to analyze whether everything works.
For that, let's first of all add a console log here
getting token to see whether this works
whenever we're trying to get the token.
And we do, getting token is being printed here.
Now still, we don't see the console log here for the data.
We get back when we request the token.
So let's add a console log here in the catch function
to see whether we got an error.
And indeed, we did get an error,
an API error that the Expo push notification service
is supported only for Expo projects
so that we need to be logged in our Expo developer account
on the computer from which we are loading the project,
and that's not the case for me here.
I'm not logged into my Expo developer account.
Now getting an Expo developer account is free.
You just need to sign up with Expo to get such an account.
And once you do have that account,
you can quit that Expo server and run Expo log in there.
And now you'll need to log in with the account
you just created.
And once you did log in,
you can start the Expo server again and reload the Expo app
on your iPhone or Android device as well.
And once you do that, once the app starts
on your real device, you should see that you now get
a log where the data that we log here
is actually such an object with a data field,
which holds that exponent push token value here.
And that's the token we'll need
to deliver push notifications to the different devices.
And what I just showed on my real iPhone
will work in exactly the same way on a real Android device.
So now let me show you how we can use that push token
to deliver push notifications.