1 00:00:02,200 --> 00:00:03,620 So let's fix that. 2 00:00:03,620 --> 00:00:04,453 And for that, 3 00:00:04,453 --> 00:00:06,130 we can go to app.js 4 00:00:06,130 --> 00:00:08,010 and there I'll import everything 5 00:00:08,010 --> 00:00:11,940 as notifications from expo-notifications 6 00:00:11,940 --> 00:00:12,960 so that there, 7 00:00:12,960 --> 00:00:15,403 even before we create the component, 8 00:00:16,400 --> 00:00:20,240 we can set up our notification handler 9 00:00:20,240 --> 00:00:22,880 where we tell the operating system 10 00:00:22,880 --> 00:00:25,170 how notifications should be handled 11 00:00:25,170 --> 00:00:26,493 if the app is running. 12 00:00:28,130 --> 00:00:29,080 And here in the end, 13 00:00:29,080 --> 00:00:31,610 we want to pass in an object 14 00:00:31,610 --> 00:00:35,420 where we define the handle notification function, 15 00:00:35,420 --> 00:00:38,470 which is an async function here, 16 00:00:38,470 --> 00:00:40,280 because it should return a promise, 17 00:00:40,280 --> 00:00:41,160 and then in here 18 00:00:41,160 --> 00:00:43,680 we simply return an object 19 00:00:43,680 --> 00:00:48,680 where I will set shouldShowAlert to true 20 00:00:48,790 --> 00:00:50,860 to tell the operating system that 21 00:00:50,860 --> 00:00:54,033 local notifications should always be shown. 22 00:00:55,470 --> 00:00:56,730 With that change made, 23 00:00:56,730 --> 00:00:57,563 let's try it again. 24 00:00:57,563 --> 00:00:59,350 Let's add both to my cart, 25 00:00:59,350 --> 00:01:00,613 click order now, 26 00:01:02,960 --> 00:01:05,350 and I still don't get anything. 27 00:01:05,350 --> 00:01:07,690 Well let's add a console.log here 28 00:01:07,690 --> 00:01:08,690 in our for loop 29 00:01:08,690 --> 00:01:10,810 and see if we're maybe having problems 30 00:01:10,810 --> 00:01:13,560 extracting the push token from the cart item, 31 00:01:13,560 --> 00:01:16,830 because I think that something has to be wrong there. 32 00:01:16,830 --> 00:01:18,570 So I'll add a new item to my cart 33 00:01:18,570 --> 00:01:19,773 and test this again. 34 00:01:21,240 --> 00:01:22,283 And I see, 35 00:01:23,220 --> 00:01:25,470 I simply named this incorrectly, 36 00:01:25,470 --> 00:01:26,570 it's productPushToken. 37 00:01:27,547 --> 00:01:29,363 That's the name I have here. 38 00:01:30,280 --> 00:01:31,113 Because, 39 00:01:31,113 --> 00:01:32,670 and that was my mistake here, 40 00:01:32,670 --> 00:01:37,630 if we do place an order from inside the cart screen, 41 00:01:37,630 --> 00:01:40,480 I mentioned it at the beginning and then forgot it again, 42 00:01:40,480 --> 00:01:43,280 we're not submitting our raw cart items. 43 00:01:43,280 --> 00:01:45,020 We are transforming them 44 00:01:45,020 --> 00:01:48,270 and there I used productPushToken as a name. 45 00:01:48,270 --> 00:01:49,493 So that's my bad. 46 00:01:50,520 --> 00:01:54,150 Let's go back here to the orders action file 47 00:01:54,150 --> 00:01:55,530 and use that proper name 48 00:01:55,530 --> 00:01:57,233 and extract the productPushToken, 49 00:01:58,250 --> 00:02:00,210 and with that we should have a push token, 50 00:02:00,210 --> 00:02:02,230 and now of course push notifications 51 00:02:02,230 --> 00:02:03,420 should be delivered. 52 00:02:03,420 --> 00:02:04,253 Nonetheless, 53 00:02:04,253 --> 00:02:05,650 adding this in app.js 54 00:02:05,650 --> 00:02:06,880 was all important 55 00:02:06,880 --> 00:02:09,000 because otherwise we wouldn't see anything 56 00:02:09,000 --> 00:02:10,890 if the app was in the foreground, 57 00:02:10,890 --> 00:02:12,500 which might be what you want, 58 00:02:12,500 --> 00:02:14,100 but which still is good to know. 59 00:02:15,470 --> 00:02:17,970 So now I added two products again. 60 00:02:17,970 --> 00:02:19,370 I'll click Order Now again, 61 00:02:19,370 --> 00:02:23,250 and now here we see our push notifications 62 00:02:23,250 --> 00:02:25,870 and we also see the information, 63 00:02:25,870 --> 00:02:28,123 the title and the body we defined. 64 00:02:29,210 --> 00:02:30,620 And that now works 65 00:02:30,620 --> 00:02:33,530 and that is how we could integrate push notifications 66 00:02:33,530 --> 00:02:35,613 in a more realistic app.