1 00:00:02,220 --> 00:00:04,960 So finally, we got that token. 2 00:00:04,960 --> 00:00:07,840 Now, here, we can retrieve that token 3 00:00:08,880 --> 00:00:13,670 by accessing data.data, 4 00:00:15,060 --> 00:00:18,200 because it's the data fields that holds the token. 5 00:00:18,200 --> 00:00:20,170 And therefore, of course, if that's confusing, 6 00:00:20,170 --> 00:00:23,010 you can, of course, alter rename that argument to response, 7 00:00:23,010 --> 00:00:24,670 to access response data. 8 00:00:24,670 --> 00:00:27,470 But ultimately that will be our token. 9 00:00:27,470 --> 00:00:31,010 Now, we'll not need that token here for the moment, 10 00:00:31,010 --> 00:00:33,430 instead, I wanna use it to manually 11 00:00:33,430 --> 00:00:37,290 send a push notification to our real device. 12 00:00:37,290 --> 00:00:39,480 And testing push notifications 13 00:00:39,480 --> 00:00:43,880 is made easy with the Expo push notification tool. 14 00:00:43,880 --> 00:00:45,450 You can find it if you search for 15 00:00:45,450 --> 00:00:47,540 Expo push notifications. 16 00:00:47,540 --> 00:00:51,030 This is a tool which allows you to test push notifications 17 00:00:51,030 --> 00:00:53,880 you wanna send to your Expo projects. 18 00:00:53,880 --> 00:00:57,460 In reality, you would probably not use this tool, 19 00:00:57,460 --> 00:01:01,930 but you would use one of Expos server side STKs 20 00:01:01,930 --> 00:01:05,160 to trigger a push notification on the server, 21 00:01:05,160 --> 00:01:08,040 or you would send it from directly inside your app, 22 00:01:08,040 --> 00:01:10,200 As I will show you later in this module, 23 00:01:10,200 --> 00:01:12,040 depending on your use case. 24 00:01:12,040 --> 00:01:14,638 But for testing, this is a great tool. 25 00:01:14,638 --> 00:01:17,140 Now, as you see, it needs this push token 26 00:01:17,140 --> 00:01:19,380 in this format, we just saw it. 27 00:01:19,380 --> 00:01:22,480 So let's copy this push token, 28 00:01:22,480 --> 00:01:27,020 this full string here, and insert it here. 29 00:01:27,020 --> 00:01:30,519 That's the identifier of my device now. 30 00:01:30,519 --> 00:01:32,550 And then we can enter a title. 31 00:01:32,550 --> 00:01:37,550 This is a test. My first test message, as a body. 32 00:01:38,250 --> 00:01:40,820 We could add extra data if we wanted to. 33 00:01:40,820 --> 00:01:44,223 That should be in Jason format then though. 34 00:01:45,970 --> 00:01:49,890 And we can also add iOS and Android specific information, 35 00:01:49,890 --> 00:01:53,320 but for the moment, I'll just send this notification. 36 00:01:53,320 --> 00:01:55,170 And now I'm sending this notification 37 00:01:55,170 --> 00:01:57,000 whilst the app is in foreground. 38 00:01:57,000 --> 00:01:59,263 It would also work if it's in background. 39 00:02:00,310 --> 00:02:02,520 And you see here's the message delivered, 40 00:02:02,520 --> 00:02:03,440 and we can tap it. 41 00:02:03,440 --> 00:02:04,950 And if we do tap it, 42 00:02:04,950 --> 00:02:08,130 we run that same code I showed you before 43 00:02:08,130 --> 00:02:10,180 for the local notifications. 44 00:02:10,180 --> 00:02:12,140 So that code for handling incoming 45 00:02:12,140 --> 00:02:15,070 background or foreground notifications, 46 00:02:15,070 --> 00:02:16,842 that code still executes, 47 00:02:16,842 --> 00:02:20,320 and it still gives us access to the notification object 48 00:02:20,320 --> 00:02:22,610 and all the notification data. 49 00:02:22,610 --> 00:02:24,620 And that's in the end, all that's to it. 50 00:02:24,620 --> 00:02:26,918 This is how we send push notifications 51 00:02:26,918 --> 00:02:29,270 in an Expo application. 52 00:02:29,270 --> 00:02:32,040 As you can see, it's really not that difficult, 53 00:02:32,040 --> 00:02:35,350 thanks to Expo's own push server, 54 00:02:35,350 --> 00:02:38,330 which in the end wraps those official servers, 55 00:02:38,330 --> 00:02:41,150 and which has done all the nitty gritty details 56 00:02:41,150 --> 00:02:45,650 of registering itself with those official service for us. 57 00:02:45,650 --> 00:02:49,080 Instead, we just use these convenient methods I showed you, 58 00:02:49,080 --> 00:02:52,090 and we can deliver push notifications. 59 00:02:52,090 --> 00:02:55,620 Now, let me show you how we can trigger push notifications 60 00:02:55,620 --> 00:02:57,603 from inside the app.