Demonstrate the handlers for the actions by writing code to change the iPhone app. This video also describes how categories and actions are handled by the framework.
- [Instructor] You're almost ready to build and run your code for actions and notifications. There's one more thing I'd like to mention before we do. The simulator for devices with 3D touch requires you to use a 3D touch trackpad. If you're using a mouse or an older trackpad, you won't be able to access actions in the simulator. Change the device to an iPhone 6 or earlier for full use of the simulator. While this code will work, it will be difficult to see the makePizza on its minute repeat interval. Head up to that code.
Comment out the trigger with the repeats in it. Uncomment the trigger with the repeats, and change the time to seven seconds. Now you're ready to run. The app appears, and because we're using a new simulator, it's going to go through the notification allow again, so go ahead and hit Allow, then go ahead and Schedule A Pizza, 15 seconds later, you get the notification. Drag down, and you'll see we now have a Snooze button.
Click the Snooze button. The notification disappears, but only for five seconds. Do it again. Hit Command + L. The notification appears again, and you'll notice it said slide for more. If it says tap for more, you're probably using an iPhone 7 or greater. Slide it over, click View, and you'll see, once again, the Snooze button. Hit Command + Shift + H twice and drag down.
Once again, you see the notification. Just click on the notification so it goes back to our app and hit the Make A Pizza. Once again you see the the Making Pizza. Drag down, and you see our two buttons from that from the two actions we did. The Next and the Stop. Click the Next, and you can see that we're starting to do the next. We Roll Dough, and it'll change again, and the next one, Add Sauce, and so on, and you can just click it to get rid of it.
You can now execute code from the background of a notification by the press of an action button. User notifications give you one more control you can use, and that we'll look at next.
- The differences between local and remote notifications
- Adding code to a demo project to get permissions
- Adding code to run notifications if a user gives permission
- Extracting content from pending and delivered notifications
- Creating in-app notifications
- Updating and removing notifications
- Getting and using a string for a text response object
- Adding and executing an action
- Adding rich content to a notification