Can an app programmatically detect if a production provisioning profile is being used? (for determination of which push environment to use)

I want to implement a scheme whereby the server gets instructed by the app during a handshake whether the server should send pushes over the Apple sandbox environment or the production environment.

There's several variations where the push environment will vary depending upon the circumstances:

  • Debug build/scheme with app installed via XCode
  • Release build/scheme with app installed via XCode
  • Developer distribution installed via .ipa/Apple Configurator app
  • Ad hoc distribution installed via .ipa/Apple Configurator app
  • App is installed from Testflight
  • App is installed from the app store

Is there a way the app can programmatically detect at run time which push server should be used and thus it can instruct the server accordingly during its handshake with it? I guess this boils down to if the app is able to programatically detect at run time if there's a production provisioning profile being used or not? Or is there some other mechanism to detect which push server should be used?

There's a couple questions/answers on Stackoverflow about programatically detecting if a provisioning profile is present but they look a bit hacky and I don't know if they can be trusted to be future proof.

Can an app programmatically detect if a production provisioning profile is being used? (for determination of which push environment to use)
 
 
Q