-: So let's fix that. 2 2
And for that, 3 3
we can go to app.js 4 4
and there I'll import everything 5 5
as notifications from expo-notifications 6 6
so that there, 7 7
even before we create the component, 8 8
we can set up our notification handler 9 9
where we tell the operating system 10 10
how notifications should be handled 11 11
if the app is running. 12 12
And here in the end, 13 13
we want to pass in an object 14 14
where we define the handle notification function, 15 15
which is an async function here, 16 16
because it should return a promise, 17 17
and then in here 18 18
we simply return an object 19 19
where I will set shouldShowAlert to true 20 20
to tell the operating system that 21 21
local notifications should always be shown. 22 22
With that change made, 23 23
let's try it again. 24 24
Let's add both to my cart, 25 25
click order now, 26 26
and I still don't get anything. 27 27
Well let's add a console.log here 28 28
in our for loop 29 29
and see if we're maybe having problems 30 30
extracting the push token from the cart item, 31 31
because I think that something has to be wrong there. 32 32
So I'll add a new item to my cart 33 33
and test this again. 34 34
And I see, 35 35
I simply named this incorrectly, 36 36
it's productPushToken. 37 37
That's the name I have here. 38 38
Because, 39 39
and that was my mistake here, 40 40
if we do place an order from inside the cart screen, 41 41
I mentioned it at the beginning and then forgot it again, 42 42
we're not submitting our raw cart items. 43 43
We are transforming them 44 44
and there I used productPushToken as a name. 45 45
So that's my bad. 46 46
Let's go back here to the orders action file 47 47
and use that proper name 48 48
and extract the productPushToken, 49 49
and with that we should have a push token, 50 50
and now of course push notifications 51 51
should be delivered. 52 52
Nonetheless, 53 53
adding this in app.js 54 54
was all important 55 55
because otherwise we wouldn't see anything 56 56
if the app was in the foreground, 57 57
which might be what you want, 58 58
but which still is good to know. 59 59
So now I added two products again. 60 60
I'll click Order Now again, 61 61
and now here we see our push notifications 62 62
and we also see the information, 63 63
the title and the body we defined. 64 64
And that now works 65 65
and that is how we could integrate push notifications 66 66
in a more realistic app.