Hi -
I'm having issuses with pushing notifications both locally and from a server to either my phone or the simulator. KEEP IN MIND I had previously had them working not an hour ago, and for some reason, after changing no code i come back to errors upon errors. I am using 17.0.2 and xcode. Here are some things i've tried:
- CloudKit's Push notification console - one day it just suddenly stopped working, and doing pushes that previously had worked suddenly gave the vague and very unhelpful error message "device was offline." I know my credentials and device token are all valid because it doesn't throw any other errors regarding that.
- AWS Pinpoint/SNS - i previously had it working sending push notifications from SNS. I get a 200 response, but it still doesn't show a push notification. I think Apple is misinterpreting "discarded as device was offline" somehow as a success?
- .apns drag-n-drop - i literally sometimes fail dragging and dropping into the simulator a properly configured .apns file to trigger a notification. Sometimes it works, sometimes it doesn't.
The literal only thing i changed was adding the target of the user notifications extension (so i can add custom actions on a notification). Unless that target somehow broke everything, Apple seems to think my device is offline. Hopefully someone might have been experiencing this and can understand my fury.
I would like to first point out the discrepancy in your question where you say "after changing no code" and then later "only thing i changed was adding the target of the user notifications extension"
This sounds like a change to your project and now more code is being executed due to the existence of the NSE. That should be the first change you should look at, and see if things go back to normal when you revert these changes.
If notifications are not reaching the device or your app, there are a multitude of reasons this could be, and is difficult to guess or diagnose remotely. Delivery issues with push notifications can usually be determined by examining the responses from APNs. The best would be to start with the Push Notifications Console at https://developer.apple.com/notifications/push-notifications-console/ which will give you a lot of diagnostic information which you may not be getting from the other tools.
APNs will return useful information both in the HTTP/2 header response, and as a JSON dictionary for unsuccessful requests. You can find the list of responses, and further troubleshooting steps in the article Handling Notification Responses from APNs:
If the above document does not help clarify the issue, or issues with receiving notifications persist despite receiving an error status neither in the HTTP/2 headers nor in the response JSON dictionary, we can assist you with diagnosing the issue.
If the console works, but things fail when you are using a 3rd party push notification provider service, we recommend to contact them first to make sure the issue is not between your app and their service, and to obtain information on any errors they might be receiving from Apple servers.
If you are stuck and would like to receive help diagnosing the issue, that is not going to be possible in a public forum due to the specific information you would need to supply. If you would like, you can request code-level support at https://developer.apple.com/support/technical/
To help diagnose the issue, they will first need some information about the push requests. Please include the following information for a failed notification:
The following are required to start a diagnosis:
- Exact time and date (including time zone) of the push request sent
- Exact time and date (including time zone) of the notification received by the device (if received at all)
- Your app’s Bundle ID
- The device token the push was sent to
- The returned (error) status and message from APNs
- Full contents of the HTTP/2 headers
- Full contents of the payload
The following are helpful for timely and accurate diagnosis of the issue:
- If using your own server to send: the public IPv4 address of the push provider server used to send the push
- If using a 3rd party service to send: the name of the 3rd party push provider service used
- The push topic (apns-topic header value)
- The push type (alert, background, VoIP, other)
- The apns-id (either from your request, or from the HTTP/2 header response)
- Any logging you have from the server side that shows the interaction with it and APNs
If you are using a 3rd party push provider service, and do not have the above necessary info, or only have the info you are providing to the provider service, please first contact the service provider for a resolution or to provide the above information.