iOS: Debugging Release/Distribution PUSH Notifications - ios

I know I have done this successfully in the past.
I have an app with different dev streams. The app is currently in the App Store, and I am trying to track down an issue related to PUSH notifications that seems to be plaguing that version only. So, I am trying to debug Production/Release PUSH notifications. I know I have done this in the past, but it has been a while, and I have forgotten the exact set of settings that allowed this to work.
App setup is as follows:
App is tied in to Azure Notification Hub.
Notification Hub has a Production APNS certificate.
Currently, PUSH notifications succeed when the app is deployed to a device either by:
Downloading from the App Store, or
Building in Release mode with a Distribution Provisioning Profile
The problem is with a particular KIND of PUSH notification, and specifically how the app responds to it (so, it's not the PUSH notification that is the problem, but I need to be able to debug incoming PUSH notifications).
I think I remember the following to enable debugging Distribution PUSH notifications:
You have to build in Release mode.
You have to build with a Development Provisioning Profile.
But something is going wrong. No matter what combination of settings I choose, I am either unable to debug my app (and then the PUSH notifications works), or I am able to debug my app (and then the PUSH notifications fail). Has something changed in Xcode, or am I making some other mistake? Like I said before, I am positive that I have been able to get this working in the past. How can I get it working now?

Related

Push notification problems with Back4App and APN Authentication Key

I'm using ParseServer with Back4App for an Android and iOS App. I implemented a Cloud Function on the server to send push notifications through Parse and it works for the Android app without any issues (for both debug and production apks).
With the iOS Version I am currently running into the following problem:
I created an APN Authentication Key that I uploaded to Back4App. In the process I indicated that this key is for a debug app, and sending push notifications via the Cloud Function to my iOS debug device works like a charm, no matter what device triggers the Cloud Function. This was sufficient for development.
I need to be able to get push notifications to both device types to troubleshoot together with my TestFlight testers in an open test I recently started.
For all TestFlight test devices, push notifications are not getting delivered - which is not surprising, given that the APN Key was uploaded to Back4App for debug apps only.
I thus reuploaded the APN Key and indicated that it is a production app, and now sending push notifications to the TestFlight testers works, but sending push notifications to my iOS debug test device does not.
I tried getting around this by changing the build scheme in Xcode from Debug to Release - but with a release version on my iOS debug device, the push notifications are still not being delivered to said device. I can see in my Parse Dashboard that they are being sent, but they are not getting delivered.
I am using a Notification Service Extension and set the Build Mode to Release there as well, but to no effect.
Changing the APN Authentication Key on Back4App back to Debug only allows me to receive push notifications again on my debug device.
I tried changing the APN Authentication Key (for either debug and production, since I cannot select both on Back4App) before force quitting the app, restarting it to get a new APN token saved to the ParseServer, and then sending the test notifications, also to no avail. I tried this for both my debug device and a TestFlight device, and it is always either my debug device (who gets the app straight from Xcode) or the TestFlight devices that are able to receive push notifications, never both.
I did not get around to trying it with APN Certificates for which I read that there are two distinct certificates for Production and Debug apps. While this option would be possible with Back4App, one big question remains - how do you implement push notifications both for debug and production apps in iOS with only one APN Authentication Key? And more specifically, how do you do that on Back4App?
Or are there any other ways around this issue besides the old APN Certificates? Since APN Authentication Keys are made out to be the future I'd rather implement it with that instead of the older APN Certificates.
Any help is appreciated, thanks in advance!
I found a workaround and what caused the issue:
Using APN Authentication Keys for push notifications is easier to implement and more convenient since keys don't expire, can be used across multiple apps and do not require the generation of independent development and production certificates.
But: An APN Authentication Key can only be used for EITHER development push notifications OR production push notifications (which is apparently intended by Apple).
No matter whether build settings are set to Release or Debug, a tethered physical device that gets any build straight from Xcode will always have the APN environment flag set to development - even manually setting the APN environment flag to production before building does not have an effect, it seems to be reset at build time and defaults to development. This means that my debug test device (physically connected to Xcode) can only receive development pushes, which explained my described issues.
When archiving a build and uploading it to TestFlight, the APN environment flag is automatically set to production; all TestFlight testers thus only receive production push notifications.
What I am doing to work around this is that I registered my debug test device as a TestFlight tester so that I can download my latest build from there and take advantage of production pushes. I registered this particular test device as its own group so that I can test builds only with that device that I do not want to immediately roll out to all other TestFlight users in my second (true) group of testers.
Does that mean I always need to archive any new builds and push it to my test device via TestFlight to try something new?
No, only for things that require push notifications. For everything else I still get the latest build straight from Xcode because all locally stored data (like a logged-in Parse User or Installation data) persists on my device, no matter whether I install a new version from Xcode directly or through TestFlight automated updates.
That way I can work as usual and only have to take the additional TestFlight step for any push notification-related features.

Push Notification (FCM) not working in a test flight mode nor in a downloadable form

I am trying to make my application work with a push notification service in a test flight mode ( essentially in a downloadable form, which is already in the app store ) but has worked in vain.
My IOS application was built with react native framework(0.39v). The application worked fine in the debug/release mode, being able to receive FCM sent from the API server or messages from Firebase console. Thinking it is ok to put the app on the appstore shelf, I uploaded the application and downloaded to my mobile. It worked expected except receiving Push Notification. It turns out that a testflight mode also shows malfunctioning of a push notification service. I am not sure why.
What would be the typical approach to deal with this issue? I reapplied the provisioning profile to the app but ended up failing. What would you recommend me to do? Might have this issue been triggered because of APNs certificate or Push Notification certificate?
If you have had similar issues, please them share with me!

Test flight push notifications work. Does that mean my push notifications will work on the app store?

I've never made an app with push notifications before until now. Currently Im doing some testing with internal users on iTunesConnect and the push notifications are coming in fine.
Because of I’ve never done this before, I wanted to ask if this means my push notifications will still work when I actually release to the store? If not, could someone explain the difference between testflight and appstore builds are?
Thanks
Yes the push notification will work on AppStore too, as there are two types of push notification certificates:
Development (Used for testing development builds)
Production (Used for production builds such as Adhoc and AppStore)
So if the push is working fine in TestFlight it will defiantly work on AppStore builds.

Push notifications works fine in development, but device not getting notification in production

Ok, so I have an app that is in the app store. In development everything works fine I get all of the notifications that I send. I should mention that we are using Firebase for analyics and push notifications as we have a iOS and Android version of the app. Firebase account has both the correct development and correct production apns cert, the app's capabilities are set correctly to include push notifications and remote notifications in the background.
In the organizer window the entitlement for apns-environement is set to production whenever uploading to the app store or when exporting the app. Whenever the app is first installed and ran the alert to allow push notifications is shown. So my apns certs have to be configured correctly.
I am a working on contract for this company, just started 3 months ago, I would hate for these people to look at me in a bad light but I really don't know where the issue is. I am also using Xcode's automatic code signing option, with the correct provisioning profile and developer account signed in the Xcode on this mac.
Just went through this and I do not know if you solved this,
I turned push off and deleted the certs from apple dev center and created them all over again and this made everything work as it should.
I also had this line of code set to,
FIRInstanceID.instanceID().setAPNSToken(deviceToken as Data, type: FIRInstanceIDAPNSTokenType.sandbox)
I will change it to .prod when I push to the app store.

iOS Push Notification Not Sending

I've been developing an app with push notifications powered through UrbanAirship and its been working great for development. The problem is when I create an Ad Hoc build. The push notifications seem to stop working. I'm not sure where the breakdown occurs, but it just doesn't seem to be working.
I have already setup my app ID for both "development" and "production" push notifications and I've added the certificates before building and releasing. I am sure that I am using the proper app ID for my distribution mobile provision as well.
I don't know what could be going wrong. Has anyone else experienced this?

Resources