So let's fix that.
And for that,
we can go to app.js
and there I'll import everything
as notifications from expo-notifications
so that there,
even before we create the component,
we can set up our notification handler
where we tell the operating system
how notifications should be handled
if the app is running.
And here in the end,
we want to pass in an object
where we define the handle notification function,
which is an async function here,
because it should return a promise,
and then in here
we simply return an object
where I will set shouldShowAlert to true
to tell the operating system that
local notifications should always be shown.
With that change made,
let's try it again.
Let's add both to my cart,
click order now,
and I still don't get anything.
Well let's add a console.log here
in our for loop
and see if we're maybe having problems
extracting the push token from the cart item,
because I think that something has to be wrong there.
So I'll add a new item to my cart
and test this again.
And I see,
I simply named this incorrectly,
it's productPushToken.
That's the name I have here.
Because,
and that was my mistake here,
if we do place an order from inside the cart screen,
I mentioned it at the beginning and then forgot it again,
we're not submitting our raw cart items.
We are transforming them
and there I used productPushToken as a name.
So that's my bad.
Let's go back here to the orders action file
and use that proper name
and extract the productPushToken,
and with that we should have a push token,
and now of course push notifications
should be delivered.
Nonetheless,
adding this in app.js
was all important
because otherwise we wouldn't see anything
if the app was in the foreground,
which might be what you want,
but which still is good to know.
So now I added two products again.
I'll click Order Now again,
and now here we see our push notifications
and we also see the information,
the title and the body we defined.
And that now works
and that is how we could integrate push notifications
in a more realistic app.