Apple Push Notification Service (APNs) is a bit complex, but I will try to make it simple to understand from a business perspective. First you need to understand that when the notification is received on the device the operating system (OS) processes this data first and most of the time never calls your app code until you click the view button.
The notification can contain a payload of data from your server to tell the OS how to present the notification and tell your app why it was notified. The payload data is very small and should only contain an ID or key to direct the app to the correct screen and content.
If your app is open when the device receives the notification then the OS will pass the payload to the app without alerting the user. This is the only time the app can code how to present the notification to the user.
If your app is closed, and the notification is an alert, the OS will give an alert to the user with the message you sent. The user can then click the view button and the app will open and receive the payload.
Once the app receives the payload it can then process it and take action based on that data. Some examples are opening the app to a certain message, order, or location.