Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't I receive iOS Push Notifications with a debug build connected to Xcode debugger?

When I test the app using a TestFlight version built by the CI machine, the device receives push notifications.

But when I rebuild the app under Xcode locally with the debugger connected, the device doesn't receive any push notifications.

To validate things further I again tested locally with a push notifications tester, and the device indeed received a push notification.

So the code isn't omitted due to it being a #DEBUG build as the grant and registrations pass.

What is my local build possibly missing?

like image 455
Sebastian Dwornik Avatar asked Mar 12 '19 23:03

Sebastian Dwornik


People also ask

Why push notification is not working for iOS?

Go to iOS' settings → "Your app name" → Notifications to ensure notifications are enabled for your app. You will need to restart your app after enabling push notifications. If you find a recent install with a push token in the debug tool, make sure your app is not opened in the foreground during your tests.

How does push notifications work on the iOS platform?

An iOS push notification is a message that pops up on an Apple device such as an iPhone. Before receiving push notifications from an app, iOS device users must explicitly give permission. Once a user opts-in, mobile app publishers can send push notifications to the users' mobile devices.


1 Answers

When you build your app in debug locally your app will generate a unique device token that doesn't receive production push notifications. When you build your app with a distribution provisioning profile it generates a different device token that does work on production.

Apple will reject a development device token unless you are specifically requesting a push notification using your APNS Sandbox certificate.

So if you haven't already you'll have to go through the certificate creation process all over again but this time for a sandbox certificate and use that one instead.

like image 177
Cameron Porter Avatar answered Oct 14 '22 03:10

Cameron Porter